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:
779 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var supportsDescriptors = require('define-properties').supportsDescriptors;
|
---|
4 | var getPolyfill = require('./polyfill');
|
---|
5 | var gOPD = Object.getOwnPropertyDescriptor;
|
---|
6 | var defineProperty = Object.defineProperty;
|
---|
7 | var TypeErr = TypeError;
|
---|
8 | var getProto = Object.getPrototypeOf;
|
---|
9 | var regex = /a/;
|
---|
10 |
|
---|
11 | module.exports = function shimFlags() {
|
---|
12 | if (!supportsDescriptors || !getProto) {
|
---|
13 | throw new TypeErr('RegExp.prototype.flags requires a true ES5 environment that supports property descriptors');
|
---|
14 | }
|
---|
15 | var polyfill = getPolyfill();
|
---|
16 | var proto = getProto(regex);
|
---|
17 | var descriptor = gOPD(proto, 'flags');
|
---|
18 | if (!descriptor || descriptor.get !== polyfill) {
|
---|
19 | defineProperty(proto, 'flags', {
|
---|
20 | configurable: true,
|
---|
21 | enumerable: false,
|
---|
22 | get: polyfill
|
---|
23 | });
|
---|
24 | }
|
---|
25 | return polyfill;
|
---|
26 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.