From 4274bcecaaa16d9fdc2881153c6347935f7b92d4 Mon Sep 17 00:00:00 2001 From: Peter Burns Date: Mon, 14 Oct 2019 19:57:51 -0700 Subject: [PATCH] Improve types for the template field on Polymer elements. (#5596) null is allowed! --- externs/polymer-externs.js | 6 +++--- lib/elements/dom-bind.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/externs/polymer-externs.js b/externs/polymer-externs.js index a1b9dae11a..06c7d6e9ba 100644 --- a/externs/polymer-externs.js +++ b/externs/polymer-externs.js @@ -41,7 +41,7 @@ PolymerInit.prototype.extends; PolymerInit.prototype.properties; /** @type {(!Array | undefined)} */ PolymerInit.prototype.observers; -/** @type {(!HTMLTemplateElement | string | undefined)} */ +/** @type {(!HTMLTemplateElement | string | undefined | null)} */ PolymerInit.prototype.template; /** @type {(!Object | undefined)} */ PolymerInit.prototype.hostAttributes; @@ -60,7 +60,7 @@ PolymerElementConstructor.extends; PolymerElementConstructor.properties; /** @type {(!Array | undefined)} */ PolymerElementConstructor.observers; -/** @type {(!HTMLTemplateElement | string | undefined)} */ +/** @type {(!HTMLTemplateElement | string | undefined | null)} */ PolymerElementConstructor.template; /** @interface */ @@ -150,7 +150,7 @@ var PolymerElement = function() {}; PolymerElement.is; /** * The template to stamp when creating this element type. - * @type {!HTMLTemplateElement|undefined} + * @type {!HTMLTemplateElement|undefined|null} */ PolymerElement.template; /** diff --git a/lib/elements/dom-bind.js b/lib/elements/dom-bind.js index 33e7293b09..e8e4a9054e 100644 --- a/lib/elements/dom-bind.js +++ b/lib/elements/dom-bind.js @@ -115,7 +115,7 @@ export class DomBind extends domBindBase { render() { let template; if (!this.__children) { - template = /** @type {HTMLTemplateElement} */(template || this.querySelector('template')); + template = /** @type {?HTMLTemplateElement} */(template || this.querySelector('template')); if (!template) { // Wait until childList changes and template should be there by then let observer = new MutationObserver(() => {