Fix plugin loading in browsers that use polyfill for HTML imports

HTML Imports polyfill resolves document.currentScript in a way that
requires additional handling to determine URL of the loaded script. With
this change, __importElement is used to locate HTML import node to
determine original plugin URL.

Bug: Issue 8647
Change-Id: Ibf6d63ab32d3b2f55272cae21b5891562f46d37a
This commit is contained in:
Viktar Donich 2018-04-09 15:16:03 -07:00
parent 935b4e9ad0
commit 06ee72b7db
2 changed files with 5 additions and 3 deletions

@ -1 +1 @@
Subproject commit 08862c06001ff24892c5459ead7ebf738893d664
Subproject commit 5e91925cfd391898e8e33fd149b9e1a115dafee4

View File

@ -449,8 +449,10 @@
};
Gerrit.install = function(callback, opt_version, opt_src) {
const src = opt_src || (document.currentScript &&
(document.currentScript.src || document.currentScript.baseURI));
// HTML import polyfill adds __importElement pointing to the import tag.
const script = document.currentScript &&
(document.currentScript.__importElement || document.currentScript);
const src = opt_src || (script && (script.src || script.baseURI));
const name = getPluginNameFromUrl(src);
if (opt_version && opt_version !== API_VERSION) {