Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sorvell committed Sep 15, 2014
1 parent 35e6cbe commit af95b49
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,14 @@ var importParser = {
},
// determine the next element in the tree which should be parsed
nextToParse: function() {
this._mayParse = [];
return !this.parsingElement && this.nextToParseInDoc(mainDoc);
},
nextToParseInDoc: function(doc, link) {
if (doc) {
// use `marParse` list to avoid looping into the same document again
// since it could cause an iloop.
if (doc && this._mayParse.indexOf(doc) < 0) {
this._mayParse.push(doc);
var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc));
for (var i=0, l=nodes.length, p=0, n; (i<l) && (n=nodes[i]); i++) {
if (!this.isParsed(n)) {
Expand Down
14 changes: 14 additions & 0 deletions test/html/imports/load-a.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--
@license
Copyright (c) 2014 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
-->
<script>
loaded = window.loaded || [];
loaded.push('a');
</script>
<link rel="import" href="load-b.html">
15 changes: 15 additions & 0 deletions test/html/imports/load-b.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
@license
Copyright (c) 2014 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
-->
<script>
loaded = window.loaded || [];
loaded.push('b');
</script>
<link rel="import" href="load-a.html">
<link rel="import" href="load-c.html">
15 changes: 15 additions & 0 deletions test/html/imports/load-c.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!--
@license
Copyright (c) 2014 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
-->
<script>
loaded = window.loaded || [];
loaded.push('c');
</script>
<link rel="import" href="load-d.html">
<link rel="import" href="load-a.html">
14 changes: 14 additions & 0 deletions test/html/imports/load-d.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--
@license
Copyright (c) 2014 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
-->
<script>
loaded = window.loaded || [];
loaded.push('d');
</script>
<link rel="import" href="load-b.html">
27 changes: 27 additions & 0 deletions test/html/load-loop.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
@license
Copyright (c) 2014 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
-->
<!doctype html>
<html>
<head>
<title>load loop Test</title>
<script src="../../../tools/test/htmltest.js"></script>
<script src="../../../tools/test/chai/chai.js"></script>
<script src="../../html-imports.js"></script>
<link rel="import" href="imports/load-a.html">
</head>
<body>
<script>
document.addEventListener('HTMLImportsLoaded', function() {
chai.assert.deepEqual(loaded, ['a', 'b', 'c', 'd']);
done();
});
</script>
</body>
</html>
1 change: 1 addition & 0 deletions test/js/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ htmlSuite('HTMLImports', function() {
htmlTest('html/style-paths.html');
htmlTest('html/load.html');
htmlTest('html/load-404.html');
htmlTest('html/load-loop.html');
htmlTest('html/base/load-base.html');
htmlTest('html/currentScript.html');
htmlTest('html/dedupe.html');
Expand Down

0 comments on commit af95b49

Please sign in to comment.