mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
Don't load imports from templates in the main doc.
This commit is contained in:
@@ -77,7 +77,7 @@ if (typeof HTMLTemplateElement === 'undefined') {
|
||||
};
|
||||
|
||||
// auto-bootstrapping for main document
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
HTMLTemplateElement.bootstrap(document);
|
||||
});
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
"../URL/URL.js",
|
||||
"../WeakMap/WeakMap.js",
|
||||
"../MutationObserver/MutationObserver.js",
|
||||
"../Template/Template.js",
|
||||
"../HTMLImports/build.json",
|
||||
"../CustomElements/build.json",
|
||||
"../Template/Template.js",
|
||||
"dom.js",
|
||||
"unresolved.js"
|
||||
]
|
||||
|
||||
61
tests/Template/imports.html
Normal file
61
tests/Template/imports.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Template with HTMLImports Test</title>
|
||||
<script src="../../src/Template/Template.js"></script>
|
||||
<script src="../../src/HTMLImports/HTMLImports.js"></script>
|
||||
<script src="../../../web-component-tester/browser.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<template id="one">
|
||||
<link rel="import" href="../HTMLImports/html/imports/script-1.html">
|
||||
</template>
|
||||
|
||||
<template id="two">
|
||||
<link rel="import" href="../HTMLImports/html/imports/csp-import-1.html">
|
||||
</template>
|
||||
|
||||
<script>
|
||||
suite('Template', function() {
|
||||
var templateOne;
|
||||
var templateTwo;
|
||||
|
||||
suiteSetup(function() {
|
||||
templateOne = document.querySelector('template#one');
|
||||
templateTwo = document.querySelector('template#two');
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
window.remoteCurrentScriptExecuted = undefined;
|
||||
window.externalScriptParsed1 = undefined;
|
||||
});
|
||||
|
||||
test('links are not imported before stamping', function() {
|
||||
assert.equal(window.remoteCurrentScriptExecuted, undefined);
|
||||
assert.equal(window.externalScriptParsed1, undefined);
|
||||
});
|
||||
|
||||
test('links are imported when stmped', function(done) {
|
||||
var imp;
|
||||
|
||||
document.body.appendChild(document.importNode(templateTwo.content, true));
|
||||
|
||||
imp = document.querySelector('[href="../HTMLImports/html/imports/csp-import-1.html"]');
|
||||
imp.addEventListener('load', function() {
|
||||
assert.ok(window.externalScriptParsed1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
23
tests/Template/runner.html
Normal file
23
tests/Template/runner.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<title>Template Tests</title>
|
||||
<meta charset="utf-8">
|
||||
<script src="../../../web-component-tester/browser.js"></script>
|
||||
|
||||
<!-- Templates -->
|
||||
<script>
|
||||
var suites = [
|
||||
'tests.html',
|
||||
'imports.html'
|
||||
];
|
||||
|
||||
WCT.loadSuites(suites);
|
||||
</script>
|
||||
@@ -19,7 +19,7 @@
|
||||
'WeakMap/tests.html',
|
||||
'MutationObserver/tests.html',
|
||||
'HTMLImports/runner.html',
|
||||
'Template/tests.html',
|
||||
'Template/runner.html',
|
||||
'CustomElements/runner.html',
|
||||
'ShadowDOM/runner.html',
|
||||
'ShadowCSS/runner.html',
|
||||
|
||||
@@ -53,9 +53,9 @@
|
||||
'URL/URL.js',
|
||||
'WeakMap/WeakMap.js',
|
||||
'MutationObserver/MutationObserver.js',
|
||||
'Template/Template.js',
|
||||
'HTMLImports/HTMLImports.js',
|
||||
'CustomElements/CustomElements.js',
|
||||
'Template/Template.js',
|
||||
// these scripts are loaded here due to polyfill timing issues
|
||||
'WebComponents/dom.js',
|
||||
'WebComponents/unresolved.js'
|
||||
|
||||
Reference in New Issue
Block a user