refactor(docs-infra): simplify custom-element polyfill setup (#25806)

PR Close #25806
This commit is contained in:
Rob Wormald
2018-09-04 11:08:47 -07:00
committed by Misko Hevery
parent d752a8907b
commit 46de203f85
4 changed files with 18 additions and 41 deletions

View File

@ -70,20 +70,18 @@
},
"private": true,
"dependencies": {
"@angular/animations": "6.0.0",
"@angular/cdk": "6.0.0",
"@angular/common": "6.0.0",
"@angular/core": "6.0.0",
"@angular/elements": "6.0.0",
"@angular/forms": "6.0.0",
"@angular/http": "6.0.0",
"@angular/material": "6.0.0",
"@angular/platform-browser": "6.0.0",
"@angular/platform-browser-dynamic": "6.0.0",
"@angular/platform-server": "6.0.0",
"@angular/router": "6.0.0",
"@angular/service-worker": "^1.0.0-beta.16",
"@webcomponents/custom-elements": "^1.0.8",
"@angular/animations": "6.1.0-rc.3",
"@angular/cdk": "6.0.2",
"@angular/common": "6.1.0-rc.3",
"@angular/core": "6.1.0-rc.3",
"@angular/elements": "6.1.0-rc.3",
"@angular/forms": "6.1.0-rc.3",
"@angular/material": "6.0.2",
"@angular/platform-browser": "6.1.0-rc.3",
"@angular/platform-browser-dynamic": "6.1.0-rc.3",
"@angular/router": "6.1.0-rc.3",
"@angular/service-worker": "6.1.0-rc.3",
"@webcomponents/custom-elements": "^1.2.0",
"classlist.js": "^1.1.20150312",
"core-js": "^2.4.1",
"jasmine": "^2.6.0",
@ -162,4 +160,4 @@
"xregexp": "^4.0.0",
"yargs": "^7.0.2"
}
}
}

View File

@ -84,28 +84,6 @@
<script nomodule src="generated/ie-polyfills.min.js"></script>
<script>
//load CE polyfill
//HACK: webpack's html plugin mangles the document.write calls if we don't trick it.
//load the ES5 shim for browsers with native CE support
function loadCustomElementsShim(){
document.write('<scri' + 'pt src="assets/js/native-shim.js"><' + '/script>');
}
//load the full custom elements polyfill for browsers without support
function loadCustomElementsPolyfill(){
document.write('<scri' + 'pt src="assets/js/custom-elements.min.js"><' + '/script>');
}
//detect if we have native CE support
if(!window.customElements){
loadCustomElementsPolyfill();
}
else {
loadCustomElementsShim();
}
</script>
</head>
<body>

View File

@ -36,7 +36,8 @@
* Zone JS is required by Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
import '@webcomponents/custom-elements'; // Custom Elements Polyfill
import '@webcomponents/custom-elements/src/native-shim';
/***************************************************************************************************

View File

@ -361,9 +361,9 @@
dependencies:
"@types/node" "*"
"@webcomponents/custom-elements@^1.0.8":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@webcomponents/custom-elements/-/custom-elements-1.0.8.tgz#b7b8ef7248f7681d1ad4286a0ada5fe3c2bc7228"
"@webcomponents/custom-elements@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@webcomponents/custom-elements/-/custom-elements-1.2.0.tgz#7fc8da6c8243b15b4f69c74c65dfe2a4996c694c"
JSONStream@^1.2.1:
version "1.3.1"