From 3ccf5966d75759a67283d99756e2976c145aab33 Mon Sep 17 00:00:00 2001 From: Martin Probst Date: Tue, 10 Dec 2019 16:50:56 +0100 Subject: [PATCH] Adjust polymer attributeChangedCallback to spec. (#40800) * Adjust polymer attributeChangedCallback to spec. According to the specification at: https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reactions `attributeChangedCallback` is called "given the attribute's local name, old value, new value, and namespace as arguments". This also matches browser implementations and understanding of how things work from discussion with Polymer engineers (CC @rictic). * Fix a dtslint issue with TypeScript <3.0. TypeScript 3.0 and before appears to be confused with the `extends` property declared here. --- types/polymer/index.d.ts | 3 ++- types/webcomponents.js/index.d.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/types/polymer/index.d.ts b/types/polymer/index.d.ts index 36a9abcce9..17217edd0c 100644 --- a/types/polymer/index.d.ts +++ b/types/polymer/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Polymer/polymer // Definitions by: Louis Grignon , Suguru Inatomi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 import { CustomElementConstructor } from "webcomponents.js"; @@ -195,7 +196,7 @@ declare global { detachedCallback?():void; - attributeChangedCallback?(name: string):void; + attributeChangedCallback?(attributeName: string, oldValue: string|null, newValue: string|null, namespace: string|null): void; extend?(prototype: Object, api: Object):Object; diff --git a/types/webcomponents.js/index.d.ts b/types/webcomponents.js/index.d.ts index 50ad3bb9c1..ded2a2ffda 100644 --- a/types/webcomponents.js/index.d.ts +++ b/types/webcomponents.js/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/webcomponents/webcomponentsjs, http://webcomponents.org // Definitions by: Adi Dahiya // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.1 export interface CustomElementInit { prototype: HTMLElement;