Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit e7ef3ae

Browse files
committed
Avoid using new URL.
1 parent d4aa275 commit e7ef3ae

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

iron-image.html

+12-5
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,10 @@
324324
if (this.src === '') {
325325
return '';
326326
}
327-
328-
var pathComponents = (new URL(this._resolveSrc(this.src))).pathname.split("/");
329-
return pathComponents[pathComponents.length - 1];
327+
// Avoid using new URL since it is not supported in IE.
328+
var resolved = this._resolveSrc(this.src);
329+
// Remove query parts, get file name.
330+
return resolved.replace(/[?|#].*/g, '').split('/').pop();
330331
},
331332

332333
_computeImgHidden: function() {
@@ -388,8 +389,14 @@
388389
},
389390

390391
_resolveSrc: function(testSrc) {
391-
var baseURI = this.$.baseURIAnchor.href;
392-
return (new URL(Polymer.ResolveUrl.resolveUrl(testSrc, baseURI), baseURI)).href;
392+
var resolved = Polymer.ResolveUrl.resolveUrl(testSrc, this.$.baseURIAnchor.href);
393+
// Avoid using new URL since it is not supported in IE.
394+
if (resolved[0] === '/') {
395+
// In IE location.origin might not work
396+
// https://connect.microsoft.com/IE/feedback/details/1763802/location-origin-is-undefined-in-ie-11-on-windows-10-but-works-on-windows-7
397+
resolved = (location.origin || location.protocol + '//' + location.host) + resolved;
398+
}
399+
return resolved;
393400
}
394401
});
395402
</script>

0 commit comments

Comments
 (0)