main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
867 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var implementation = require('./implementation');
|
---|
4 |
|
---|
5 | var supportsDescriptors = require('define-properties').supportsDescriptors;
|
---|
6 | var $gOPD = Object.getOwnPropertyDescriptor;
|
---|
7 |
|
---|
8 | module.exports = function getPolyfill() {
|
---|
9 | if (supportsDescriptors && (/a/mig).flags === 'gim') {
|
---|
10 | var descriptor = $gOPD(RegExp.prototype, 'flags');
|
---|
11 | if (
|
---|
12 | descriptor
|
---|
13 | && typeof descriptor.get === 'function'
|
---|
14 | && typeof RegExp.prototype.dotAll === 'boolean'
|
---|
15 | && typeof RegExp.prototype.hasIndices === 'boolean'
|
---|
16 | ) {
|
---|
17 | /* eslint getter-return: 0 */
|
---|
18 | var calls = '';
|
---|
19 | var o = {};
|
---|
20 | Object.defineProperty(o, 'hasIndices', {
|
---|
21 | get: function () {
|
---|
22 | calls += 'd';
|
---|
23 | }
|
---|
24 | });
|
---|
25 | Object.defineProperty(o, 'sticky', {
|
---|
26 | get: function () {
|
---|
27 | calls += 'y';
|
---|
28 | }
|
---|
29 | });
|
---|
30 | if (calls === 'dy') {
|
---|
31 | return descriptor.get;
|
---|
32 | }
|
---|
33 | }
|
---|
34 | }
|
---|
35 | return implementation;
|
---|
36 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.