Skip to content

Cache URL#toString#1533

Open
johnzhou721 wants to merge 3 commits into
zloirock:masterfrom
johnzhou721:patch-8
Open

Cache URL#toString#1533
johnzhou721 wants to merge 3 commits into
zloirock:masterfrom
johnzhou721:patch-8

Conversation

@johnzhou721
Copy link
Copy Markdown
Contributor

Caches this method so if someone replaces URL#toString after they import core-js, things will not break.

'use strict';
var $ = require('../internals/export');
var call = require('../internals/function-call');
var toString = URL.prototype.toString;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will not work in the pure version and old engines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... so is this problem perhaps repairable? Or is it a fundamental limitation of old engines?

Can you be more specific about why this won't work in pure?

Copy link
Copy Markdown
Owner

@zloirock zloirock Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL is missed in old / ES-only engines. Global URL is missed after polyfilling in the pure version.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use, for example, get-built-in-prototype-method.

Refactor URL.prototype.toString to use getBuiltInPrototypeMethod.
@johnzhou721
Copy link
Copy Markdown
Contributor Author

@zloirock This is ready for another look from you — Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants