Skip to content

Commit

Permalink
drop .bind dep from some init time cases, simplify with .forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 9, 2023
1 parent 3f17dd5 commit 712bead
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions packages/core-js/modules/web.url.constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ var $ = require('../internals/export');
var USE_NATIVE_URL = require('../internals/url-constructor-detection');
var global = require('../internals/global');
var getBuiltInStaticMethod = require('../internals/get-built-in-static-method');
var bind = require('../internals/function-bind');
var uncurryThis = require('../internals/function-uncurry-this');
var defineBuiltIn = require('../internals/define-built-in');
var defineBuiltInAccessor = require('../internals/define-built-in-accessor');
Expand Down Expand Up @@ -1014,16 +1013,13 @@ defineBuiltIn(URLPrototype, 'toString', function toString() {
return getInternalURLState(this).serialize();
}, { enumerable: true });

if (NativeURL) {
var nativeCreateObjectURL = NativeURL.createObjectURL;
var nativeRevokeObjectURL = NativeURL.revokeObjectURL;
// `URL.createObjectURL` method
// https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
if (nativeCreateObjectURL) defineBuiltIn(URLConstructor, 'createObjectURL', bind(nativeCreateObjectURL, NativeURL));
// `URL.revokeObjectURL` method
// https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
if (nativeRevokeObjectURL) defineBuiltIn(URLConstructor, 'revokeObjectURL', bind(nativeRevokeObjectURL, NativeURL));
}
// `URL.createObjectURL` method
// https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL
// `URL.revokeObjectURL` method
// https://developer.mozilla.org/en-US/docs/Web/API/URL/revokeObjectURL
if (NativeURL) ['createObjectURL', 'revokeObjectURL'].forEach(function (method) {
if (NativeURL[method]) defineBuiltIn(URLConstructor, method, NativeURL[method].bind(NativeURL));
});

setToStringTag(URLConstructor, 'URL');

Expand Down

0 comments on commit 712bead

Please sign in to comment.