|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 | var globalThis = require('../internals/global-this');
|
|---|
| 3 | var fails = require('../internals/fails');
|
|---|
| 4 |
|
|---|
| 5 | // babel-minify and Closure Compiler transpiles RegExp('.', 'd') -> /./d and it causes SyntaxError
|
|---|
| 6 | var RegExp = globalThis.RegExp;
|
|---|
| 7 |
|
|---|
| 8 | var FLAGS_GETTER_IS_CORRECT = !fails(function () {
|
|---|
| 9 | var INDICES_SUPPORT = true;
|
|---|
| 10 | try {
|
|---|
| 11 | RegExp('.', 'd');
|
|---|
| 12 | } catch (error) {
|
|---|
| 13 | INDICES_SUPPORT = false;
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | var O = {};
|
|---|
| 17 | // modern V8 bug
|
|---|
| 18 | var calls = '';
|
|---|
| 19 | var expected = INDICES_SUPPORT ? 'dgimsy' : 'gimsy';
|
|---|
| 20 |
|
|---|
| 21 | var addGetter = function (key, chr) {
|
|---|
| 22 | // eslint-disable-next-line es/no-object-defineproperty -- safe
|
|---|
| 23 | Object.defineProperty(O, key, { get: function () {
|
|---|
| 24 | calls += chr;
|
|---|
| 25 | return true;
|
|---|
| 26 | } });
|
|---|
| 27 | };
|
|---|
| 28 |
|
|---|
| 29 | var pairs = {
|
|---|
| 30 | dotAll: 's',
|
|---|
| 31 | global: 'g',
|
|---|
| 32 | ignoreCase: 'i',
|
|---|
| 33 | multiline: 'm',
|
|---|
| 34 | sticky: 'y'
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 | if (INDICES_SUPPORT) pairs.hasIndices = 'd';
|
|---|
| 38 |
|
|---|
| 39 | for (var key in pairs) addGetter(key, pairs[key]);
|
|---|
| 40 |
|
|---|
| 41 | // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|---|
| 42 | var result = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags').get.call(O);
|
|---|
| 43 |
|
|---|
| 44 | return result !== expected || calls !== expected;
|
|---|
| 45 | });
|
|---|
| 46 |
|
|---|
| 47 | module.exports = { correct: FLAGS_GETTER_IS_CORRECT };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.