Skip to content

Commit

Permalink
RegExp.prototype not an instance web compatibility workaround
Browse files Browse the repository at this point in the history
This patch makes a change to ES2015 RegExp semantics to prevent
certain property accesses and method calls from throwing. Although
the feature testing patterns here are dispreferred, they were found
necessary to ensure web compatibility of ES2015-based RegExp
semantics with respect to old versions of certain libraries.

This closes tc39#262.
  • Loading branch information
littledan committed Apr 1, 2016
1 parent 44adca8 commit d1a4e24
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -28965,7 +28965,9 @@ <h1>get RegExp.prototype.global</h1>
<emu-alg>
1. Let _R_ be the *this* value.
1. If Type(_R_) is not Object, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot,
1. If SameValue(_R_, %RegExpPrototype%), return *undefined*.
1. Otherwise, throw a *TypeError* exception.
1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot.
1. If _flags_ contains the code unit `"g"`, return *true*.
1. Return *false*.
Expand All @@ -28979,7 +28981,9 @@ <h1>get RegExp.prototype.ignoreCase</h1>
<emu-alg>
1. Let _R_ be the *this* value.
1. If Type(_R_) is not Object, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot,
1. If SameValue(_R_, %RegExpPrototype%), return *undefined*.
1. Otherwise, throw a *TypeError* exception.
1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot.
1. If _flags_ contains the code unit `"i"`, return *true*.
1. Return *false*.
Expand Down Expand Up @@ -29030,7 +29034,9 @@ <h1>get RegExp.prototype.multiline</h1>
<emu-alg>
1. Let _R_ be the *this* value.
1. If Type(_R_) is not Object, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot,
1. If SameValue(_R_, %RegExpPrototype%), return *undefined*.
1. Otherwise, throw a *TypeError* exception.
1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot.
1. If _flags_ contains the code unit `"m"`, return *true*.
1. Return *false*.
Expand Down Expand Up @@ -29130,8 +29136,10 @@ <h1>get RegExp.prototype.source</h1>
<emu-alg>
1. Let _R_ be the *this* value.
1. If Type(_R_) is not Object, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalSource]] internal slot, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalSource]] internal slot,
1. If SameValue(_R_, %RegExpPrototype%), return `"(?:)"`.
1. Otherwise, throw a *TypeError* exception.
1. Assert: _R_ has an [[OriginalFlags]] internal slot.
1. Let _src_ be the value of _R_'s [[OriginalSource]] internal slot.
1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot.
1. Return EscapeRegExpPattern(_src_, _flags_).
Expand Down Expand Up @@ -29216,7 +29224,9 @@ <h1>get RegExp.prototype.sticky</h1>
<emu-alg>
1. Let _R_ be the *this* value.
1. If Type(_R_) is not Object, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot,
1. If SameValue(_R_, %RegExpPrototype%), return *undefined*.
1. Otherwise, throw a *TypeError* exception.
1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot.
1. If _flags_ contains the code unit `"y"`, return *true*.
1. Return *false*.
Expand Down Expand Up @@ -29259,7 +29269,9 @@ <h1>get RegExp.prototype.unicode</h1>
<emu-alg>
1. Let _R_ be the *this* value.
1. If Type(_R_) is not Object, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot,
1. If SameValue(_R_, %RegExpPrototype%), return *undefined*.
1. Otherwise, throw a *TypeError* exception.
1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot.
1. If _flags_ contains the code unit `"u"`, return *true*.
1. Return *false*.
Expand Down

0 comments on commit d1a4e24

Please sign in to comment.