From 9aba9cbe003effb5ea61466bc50c3d956472b980 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 19 Sep 2026 02:09:54 +0000 Subject: [PATCH 1/2] Initial plan From 25fbefe68efe54a8f7faae6a9ffaf009f867ed85 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 19 Sep 2026 02:25:16 +0000 Subject: [PATCH 2/2] Allow kebab-case indexing on CSSStyleDeclaration Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com> --- tsc/internal/bundled/libs/lib.dom.d.ts | 4 ++++ .../cssStyleDeclarationKebabCaseIndex.js | 13 +++++++++++ .../cssStyleDeclarationKebabCaseIndex.symbols | 17 ++++++++++++++ .../cssStyleDeclarationKebabCaseIndex.types | 23 +++++++++++++++++++ .../cssStyleDeclarationKebabCaseIndex.ts | 7 ++++++ 5 files changed, 64 insertions(+) create mode 100644 tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.js create mode 100644 tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.symbols create mode 100644 tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.types create mode 100644 tsc/testdata/tests/cases/compiler/cssStyleDeclarationKebabCaseIndex.ts diff --git a/tsc/internal/bundled/libs/lib.dom.d.ts b/tsc/internal/bundled/libs/lib.dom.d.ts index 9e127c3f5a524..b6a3f1c8f43ad 100644 --- a/tsc/internal/bundled/libs/lib.dom.d.ts +++ b/tsc/internal/bundled/libs/lib.dom.d.ts @@ -6587,6 +6587,10 @@ interface CSSStyleDeclarationBase { */ setProperty(property: string, value: string | null, priority?: string): void; [index: number]: string; + /** + * CSS properties can also be accessed using their kebab-case (dashed) names, e.g. `style['background-color']`. + */ + [index: string]: any; } interface CSSStyleDeclaration extends CSSStyleProperties { diff --git a/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.js b/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.js new file mode 100644 index 0000000000000..9bc40fe74b797 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/cssStyleDeclarationKebabCaseIndex.ts] //// + +//// [cssStyleDeclarationKebabCaseIndex.ts] +declare const el: HTMLElement; + +const value = getComputedStyle(el)["background-color"]; +el.style["background-color"] = "red"; + + +//// [cssStyleDeclarationKebabCaseIndex.js] +"use strict"; +const value = getComputedStyle(el)["background-color"]; +el.style["background-color"] = "red"; diff --git a/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.symbols b/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.symbols new file mode 100644 index 0000000000000..9baac0f1a4c04 --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/cssStyleDeclarationKebabCaseIndex.ts] //// + +=== cssStyleDeclarationKebabCaseIndex.ts === +declare const el: HTMLElement; +>el : Symbol(el, Decl(cssStyleDeclarationKebabCaseIndex.ts, 0, 13)) +>HTMLElement : Symbol(HTMLElement, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + +const value = getComputedStyle(el)["background-color"]; +>value : Symbol(value, Decl(cssStyleDeclarationKebabCaseIndex.ts, 2, 5)) +>getComputedStyle : Symbol(getComputedStyle, Decl(lib.dom.d.ts, --, --)) +>el : Symbol(el, Decl(cssStyleDeclarationKebabCaseIndex.ts, 0, 13)) + +el.style["background-color"] = "red"; +>el.style : Symbol(ElementCSSInlineStyle.style, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) +>el : Symbol(el, Decl(cssStyleDeclarationKebabCaseIndex.ts, 0, 13)) +>style : Symbol(ElementCSSInlineStyle.style, Decl(lib.dom.d.ts, --, --), Decl(lib.dom.d.ts, --, --)) + diff --git a/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.types b/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.types new file mode 100644 index 0000000000000..d8e3f4c36e5bc --- /dev/null +++ b/tsc/testdata/baselines/reference/compiler/cssStyleDeclarationKebabCaseIndex.types @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/cssStyleDeclarationKebabCaseIndex.ts] //// + +=== cssStyleDeclarationKebabCaseIndex.ts === +declare const el: HTMLElement; +>el : HTMLElement + +const value = getComputedStyle(el)["background-color"]; +>value : any +>getComputedStyle(el)["background-color"] : any +>getComputedStyle(el) : CSSStyleDeclaration +>getComputedStyle : (elt: Element, pseudoElt?: string | null) => CSSStyleDeclaration +>el : HTMLElement +>"background-color" : "background-color" + +el.style["background-color"] = "red"; +>el.style["background-color"] = "red" : "red" +>el.style["background-color"] : any +>el.style : CSSStyleDeclaration +>el : HTMLElement +>style : CSSStyleDeclaration +>"background-color" : "background-color" +>"red" : "red" + diff --git a/tsc/testdata/tests/cases/compiler/cssStyleDeclarationKebabCaseIndex.ts b/tsc/testdata/tests/cases/compiler/cssStyleDeclarationKebabCaseIndex.ts new file mode 100644 index 0000000000000..3c0b4e1c02b6a --- /dev/null +++ b/tsc/testdata/tests/cases/compiler/cssStyleDeclarationKebabCaseIndex.ts @@ -0,0 +1,7 @@ +// @lib: dom,es2015 +// @noImplicitAny: true + +declare const el: HTMLElement; + +const value = getComputedStyle(el)["background-color"]; +el.style["background-color"] = "red";