Fix synchronous loading for ES5 build (#17174)

This commit is contained in:
Steve Repsher 2023-08-15 13:48:51 -04:00 committed by GitHub
parent cba246fc7f
commit 88ff4c2fa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 20 deletions

View File

@ -1,18 +1,23 @@
<script> <script>
function _ls(src) { function _ls(src, sync) {
var doc = document.documentElement; var script = document.createElement("script");
var script = doc.insertBefore( if (sync) {
document.createElement("script"), script.async = false;
doc.lastChild }
);
script.defer = true;
script.src = src; script.src = src;
return script; return document.head.appendChild(script);
} }
window.polymerSkipLoadingFontRoboto = true; window.polymerSkipLoadingFontRoboto = true;
if (!("customElements" in window && if (
"content" in document.createElement("template"))) { !(
document.write("<script src='/static/polyfills/webcomponents-bundle.js'><"+"/script>"); "customElements" in window &&
"content" in document.createElement("template")
)
) {
_ls("/static/polyfills/webcomponents-bundle.js", true);
} }
var isS11_12 = /(?:.*(?:iPhone|iPad).*OS (?:11|12)_\d)|(?:.*Version\/(?:11|12)(?:\.\d+)*.*Safari\/)/.test(navigator.userAgent); var isS11_12 =
</script> /(?:.*(?:iPhone|iPad).*OS (?:11|12)_\d)|(?:.*Version\/(?:11|12)(?:\.\d+)*.*Safari\/)/.test(
navigator.userAgent
);
</script>

View File

@ -9,7 +9,7 @@
} }
<% } else { %> <% } else { %>
<% for (const entry of es5EntryJS) { %> <% for (const entry of es5EntryJS) { %>
_ls("<%= entry %>"); _ls("<%= entry %>", true);
<% } %> <% } %>
<% } %> <% } %>
} }

View File

@ -112,7 +112,7 @@
} }
<% } else { %> <% } else { %>
<% for (const entry of es5EntryJS) { %> <% for (const entry of es5EntryJS) { %>
_ls("<%= entry %>"); _ls("<%= entry %>", true);
<% } %> <% } %>
<% } %> <% } %>
} }