From 604856b2f196bca16cb2c336829586a8b93dee4d Mon Sep 17 00:00:00 2001 From: Russell Bicknell Date: Tue, 28 Apr 2020 14:59:11 -0700 Subject: [PATCH] Update Closure types for overridden setAttribute in LegacyElementMixin. --- gen-tsd.json | 3 ++- lib/legacy/legacy-element-mixin.js | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/gen-tsd.json b/gen-tsd.json index abb67b6cab..475d21b2cf 100644 --- a/gen-tsd.json +++ b/gen-tsd.json @@ -8,7 +8,8 @@ "index.html" ], "excludeIdentifiers": [ - "templatizedBase" + "templatizedBase", + "setAttribute" ], "removeReferences": [ "../shadycss/apply-shim.d.ts", diff --git a/lib/legacy/legacy-element-mixin.js b/lib/legacy/legacy-element-mixin.js index cfa17c6f0d..c443ca7ef8 100644 --- a/lib/legacy/legacy-element-mixin.js +++ b/lib/legacy/legacy-element-mixin.js @@ -145,9 +145,15 @@ export const LegacyElementMixin = dedupingMixin((base) => { /** * Sets the value of an attribute. + * + * NOTE: This function is explicitly excluded when running + * gen-typescript-declarations because the function it overrides has + * different signatures in Closure and TypeScript's built-in types. This + * function's signature should match the signature from Closure: + * https://github.com/google/closure-compiler/blob/8972fd4e9b0689e7ebdeea53580521c819f6aecc/externs/browser/w3c_dom1.js#L686-L694 * @override * @param {string} name The name of the attribute to change. - * @param {string} value The new attribute value. + * @param {string|number|boolean|!TrustedHTML|!TrustedScriptURL|!TrustedURL} value The new attribute value. */ setAttribute(name, value) { if (legacyNoObservedAttributes && !this._legacyForceObservedAttributes) {