Skip to content

Commit

Permalink
Leave back-references intact
Browse files Browse the repository at this point in the history
This fixes an issue that was caused by an upstream bug in regjsparser.

Closes #4.
  • Loading branch information
mathiasbynens committed Sep 2, 2014
1 parent 39febe5 commit 8726d13
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ console.log([
## Known limitations

1. _regexpu_ only transpiles regular expression _literals_, so things like `RegExp('…', 'u')` are not affected.
2. It doesn’t polyfill [the `RegExp.prototype.unicode` getter](https://mths.be/es6#sec-get-regexp.prototype.unicode) because it’s not possible to do so without side effects.
2. _regexpu_ doesn’t polyfill [the `RegExp.prototype.unicode` getter](https://mths.be/es6#sec-get-regexp.prototype.unicode) because it’s not possible to do so without side effects.
3. _regexpu_ doesn’t support [canonicalizing the contents of back-references in regular expressions with both the `i` and `u` flag set](https://github.com/mathiasbynens/regexpu/issues/4), since that would require transpiling/wrapping strings.

## Installation

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
"esprima": "git+https://github.com/mathiasbynens/esprima-es6-regexp.git",
"recast": "^0.7.0",
"regenerate": "^0.6.4",
"regjsgen": "^0.1.2",
"regjsparser": "^0.1.0"
"regjsgen": "^0.2.0",
"regjsparser": "^0.1.2"
},
"devDependencies": {
"coveralls": "^2.11.1",
Expand Down
2 changes: 1 addition & 1 deletion src/rewrite-pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function processTerm(item) {
case 'anchor':
case 'empty':
case 'group':
case 'ref':
case 'reference':
// Nothing to do here.
break;
// The `default` clause is only here as a safeguard; it should never be
Expand Down
5 changes: 5 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ var fixtures = [
'pattern': '\uD834\uDF06{2,4}',
'flags': FLAGS_WITH_UNICODE,
'transpiled': '(?:\\uD834\\uDF06){2,4}'
},
{
'pattern': '(a)\\1',
'flags': FLAGS_WITH_UNICODE_WITHOUT_I,
'transpiled': '(a)\\1'
}
];

Expand Down

0 comments on commit 8726d13

Please sign in to comment.