diff --git a/lib/utils/templatize.html b/lib/utils/templatize.html index 9235220c18..b3d178e5cb 100644 --- a/lib/utils/templatize.html +++ b/lib/utils/templatize.html @@ -503,7 +503,7 @@ // Under strictTemplatePolicy, the templatized element must be owned // by a (trusted) Polymer element, indicated by existence of _methodHost; // e.g. for dom-if & dom-repeat in main document, _methodHost is null - if (Polymer.strictTemplatePolicy && !owner._methodHost) { + if (Polymer.strictTemplatePolicy && !findMethodHost(template)) { throw new Error('strictTemplatePolicy: template owner not trusted'); } options = /** @type {!TemplatizeOptions} */(options || {}); diff --git a/test/unit/strict-template-policy.html b/test/unit/strict-template-policy.html index f55e5a3750..706273115c 100644 --- a/test/unit/strict-template-policy.html +++ b/test/unit/strict-template-policy.html @@ -19,10 +19,9 @@ // the call stack to the dom methods that provoked them, so need // to catch them here and prevent mocha from complaining about them window.addEventListener('error', event => { - event.preventDefault(); - event.stopImmediatePropagation(); - if (!window.uncaughtError) { - window.uncaughtError = event; + if (window.uncaughtErrorFilter && window.uncaughtErrorFilter(event)) { + event.preventDefault(); + event.stopImmediatePropagation(); } }); @@ -39,7 +38,9 @@ try { callback(); } catch(error) { - window.onerror(error); + if (!window.uncaughtErrorFilter || !window.uncaughtErrorFilter(error)) { + throw error; + } } }); }; @@ -69,6 +70,55 @@ + + + + + + + + + +