Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

IE10 "Syntax error in regular expression" when using DatePipe in Angular 2 #270

Open
viliks opened this issue Mar 29, 2017 · 2 comments
Open

Comments

@viliks
Copy link

viliks commented Mar 29, 2017

This may not be Angular 2 specific, but I am using angular-cli 1.0.0 with intl polyfills:

import 'intl';
import 'intl/locale-data/jsonp/sk-SK.js'; 

When formatting with date pipe, itl crashes with "Syntax error in regular expression".
It happens after regex optimization in intl:

        // Shorten the regex by replacing each part of the expression with a match
        // for a string of that exact length.  This is safe for the type of
        // expressions generated above, because the expression matches the whole
        // match string, so we know each group and each segment between capturing
        // groups can be matched by its length alone.
        var exprStr = exprStr.replace(/(\\\(|\\\)|[^()])+/g, function (match) {
             return '[\\s\\S]{' + match.replace('\\', '').length + '}';
        });

If I comment out this reqex shortening, everything is working fine.
Example of exprStr that is incorrectly shortened before shortening:
\\\{\\((((((((())))))))\})
After:
[\s\S]{6}(((((((())))))))[\s\S]{1})

@caridy
Copy link
Collaborator

caridy commented Mar 30, 2017

Did you try to disabled the regexp cache? More details here: https://github.com/andyearnshaw/Intl.js#locale-data, read the second paragraph, and let us know.

@viliks
Copy link
Author

viliks commented Apr 1, 2017

Yes, disabling the regexp cache helps.
I did not find it previously, but the same issue with Date pipe was mentioned in
#231

fabianishere added a commit to fabianishere/next.js that referenced this issue Apr 10, 2020
This change adds a workaround for an issue with the Intl.js polyfill
library where it instantiates an invalid regular expression.

Relevant issues:
andyearnshaw/Intl.js#270
andyearnshaw/Intl.js#256
andyearnshaw/Intl.js#306

Until this issue is fixed upstream, we use a workaround in the example.

Fixes: vercel#11777
fabianishere added a commit to fabianishere/next.js that referenced this issue Apr 10, 2020
This change adds a workaround for an issue with the Intl.js polyfill
library where it instantiates an invalid regular expression.

Relevant issues:
andyearnshaw/Intl.js#270
andyearnshaw/Intl.js#256
andyearnshaw/Intl.js#306

Until this issue is fixed upstream, we use a workaround in the example.

Fixes: vercel#11777
Timer pushed a commit to vercel/next.js that referenced this issue Apr 13, 2020
* Add workaround for Intl.js RegEx issue

This change adds a workaround for an issue with the Intl.js polyfill
library where it instantiates an invalid regular expression.

Relevant issues:
andyearnshaw/Intl.js#270
andyearnshaw/Intl.js#256
andyearnshaw/Intl.js#306

Until this issue is fixed upstream, we use a workaround in the example.

Fixes: #11777

* Do not load Intl.js polyfill by default on Node

This change updates the `with-react-intl` example to prevent it from
polyfilling `Intl` in a Node environment when it is not needed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants