From 45a73ffff3259172cc09ee488cdb9a74cd61e0e3 Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Tue, 26 Nov 2013 09:18:55 -0800 Subject: [PATCH] Fixes https://github.com/Polymer/HTMLImports/issues/40 --- src/Parser.js | 8 ++++++-- test/html/dynamic.html | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 test/html/dynamic.html diff --git a/src/Parser.js b/src/Parser.js index 0d41be1..019ba63 100644 --- a/src/Parser.js +++ b/src/Parser.js @@ -23,6 +23,10 @@ var importParser = { script: 'parseScript', style: 'parseGeneric' }, + // TODO(sorvell): because dynamic imports are not supported, users are + // writing code like in https://github.com/Polymer/HTMLImports/issues/40 + // as a workaround. The code here checking for the existence of + // document.scripts is here only to support the workaround. parse: function(document) { if (!document.__importParsed) { // only parse once @@ -30,14 +34,14 @@ var importParser = { // all parsable elements in inDocument (depth-first pre-order traversal) var elts = document.querySelectorAll(importParser.selectors); // memoize the number of scripts - var scriptCount = document.scripts.length; + var scriptCount = document.scripts ? document.scripts.length : 0; // for each parsable node type, call the mapped parsing method for (var i=0, e; i + + + HTML Imports Dynamic + + + + + + + + +