Skip to content

FF148 Legacy RegExp features#28999

Open
hamishwillee wants to merge 4 commits intomdn:mainfrom
hamishwillee:ff148_regexp_legacy
Open

FF148 Legacy RegExp features#28999
hamishwillee wants to merge 4 commits intomdn:mainfrom
hamishwillee:ff148_regexp_legacy

Conversation

@hamishwillee
Copy link
Contributor

@hamishwillee hamishwillee commented Feb 9, 2026

FF implements the TC39 Legacy RegExp features in JavaScript in https://bugzilla.mozilla.org/show_bug.cgi?id=1306461.

This makes RegExp.prototyp.compile() throw if called on a RegExp subclass or cross realm. It also normalizes the static properties that get populated when a regexp is evaluated. There is an excellent overview of the specific implementation in https://blogs.igalia.com/compilers/2026/01/20/legacy-regexp-features-in-javascript/

I used this test script in console on browserstack to get Safari version. Chrome not supported. Did not test Bun/NodeJS - have set to False.

// 1. Create a "new global" using an iframe
const iframe = document.createElement('iframe');
document.body.appendChild(iframe);

// 2. Get the RegExp constructor from the iframe's realm
const foreignRegExp = iframe.contentWindow.RegExp;

// 3. Create a regex object inside that iframe
const re = new foreignRegExp("x");

try {
  // 4. Try to use the PARENT's compile method on the IFRAME's object
  RegExp.prototype.compile.call(re, "y");
} catch (e) {
  console.error(e); // TypeError: RegExp operation not permitted on object from different realm

Related docs work can be tracked in mdn/content#42746

@github-actions github-actions bot added data:js Compat data for JS/ECMAScript features. https://developer.mozilla.org/docs/Web/JavaScript size:m [PR only] 25-100 LoC changed labels Feb 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

Tip: Review these changes grouped by change (recommended for most PRs), or grouped by feature (for large PRs).

@hamishwillee hamishwillee requested a review from caugner February 16, 2026 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:js Compat data for JS/ECMAScript features. https://developer.mozilla.org/docs/Web/JavaScript size:m [PR only] 25-100 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants