Skip to content

Commit

Permalink
Give correct RegExp flags in toString
Browse files Browse the repository at this point in the history
When the flags property is not available on RegExp, the internals
regexp-flags implementation should be used regardless of DESCRIPTORS.

Fixes: zloirock#536
  • Loading branch information
bz2 committed Apr 29, 2019
1 parent 2eb6e7e commit 54f790e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/core-js/modules/es.regexp.to-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
var anObject = require('../internals/an-object');
var fails = require('../internals/fails');
var flags = require('../internals/regexp-flags');
var DESCRIPTORS = require('../internals/descriptors');
var TO_STRING = 'toString';
var nativeToString = /./[TO_STRING];

Expand All @@ -16,6 +15,6 @@ if (NOT_GENERIC || INCORRECT_NAME) {
require('../internals/redefine')(RegExp.prototype, TO_STRING, function toString() {
var R = anObject(this);
return '/'.concat(R.source, '/',
'flags' in R ? R.flags : !DESCRIPTORS && R instanceof RegExp ? flags.call(R) : undefined);
'flags' in R || !(R instanceof RegExp) ? R.flags : flags.call(R));
}, { unsafe: true });
}

0 comments on commit 54f790e

Please sign in to comment.