main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var PROPER_FUNCTION_NAME = require('../internals/function-name').PROPER;
|
---|
3 | var defineBuiltIn = require('../internals/define-built-in');
|
---|
4 | var anObject = require('../internals/an-object');
|
---|
5 | var $toString = require('../internals/to-string');
|
---|
6 | var fails = require('../internals/fails');
|
---|
7 | var getRegExpFlags = require('../internals/regexp-get-flags');
|
---|
8 |
|
---|
9 | var TO_STRING = 'toString';
|
---|
10 | var RegExpPrototype = RegExp.prototype;
|
---|
11 | var nativeToString = RegExpPrototype[TO_STRING];
|
---|
12 |
|
---|
13 | var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) !== '/a/b'; });
|
---|
14 | // FF44- RegExp#toString has a wrong name
|
---|
15 | var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name !== TO_STRING;
|
---|
16 |
|
---|
17 | // `RegExp.prototype.toString` method
|
---|
18 | // https://tc39.es/ecma262/#sec-regexp.prototype.tostring
|
---|
19 | if (NOT_GENERIC || INCORRECT_NAME) {
|
---|
20 | defineBuiltIn(RegExpPrototype, TO_STRING, function toString() {
|
---|
21 | var R = anObject(this);
|
---|
22 | var pattern = $toString(R.source);
|
---|
23 | var flags = $toString(getRegExpFlags(R));
|
---|
24 | return '/' + pattern + '/' + flags;
|
---|
25 | }, { unsafe: true });
|
---|
26 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.