You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
element.style[key] = value throws implicit any error #11914
// Introduced in DOM Level 2:
interface CSSStyleDeclaration {
attribute DOMString cssText;
// raises(DOMException) on setting
DOMString getPropertyValue(in DOMString propertyName);
CSSValue getPropertyCSSValue(in DOMString propertyName);
DOMString removeProperty(in DOMString propertyName)
raises(DOMException);
DOMString getPropertyPriority(in DOMString propertyName);
void setProperty(in DOMString propertyName,
in DOMString value,
in DOMString priority)
raises(DOMException);
readonly attribute unsigned long length;
DOMString item(in unsigned long index);
readonly attribute CSSRule parentRule;
};
There is no string indexer on CSSStyleDeclaration.
The statement : div.style["position"] is a JavaScript alternative way to access the property div.style.position, which is not possible in TypeScript.
The statement : div.style["position"] is a JavaScript alternative way to access the property div.style.position, which is not possible in TypeScript.
This is not accurate. both div.style["position"] and div.style.position work as intended. both resolve to the same property and both have the type string.
This is another manifestation of #7730 which is basically that:
constposition="position";div.style[position]// should behave the same way as div.style["position"]
Activity
aluanhaddad commentedon Oct 29, 2016
This behavior is correct. Specifically,
element.styleis typed as aCSSStyleDeclarationwhich is declared inlib.dom.d.tsasakarzazi commentedon Oct 30, 2016
From W3C : https://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
There is no string indexer on CSSStyleDeclaration.
The statement :
div.style["position"]is a JavaScript alternative way to access the propertydiv.style.position, which is not possible in TypeScript.mhegazy commentedon Oct 30, 2016
This is not accurate. both
div.style["position"]anddiv.style.positionwork as intended. both resolve to the same property and both have the typestring.This is another manifestation of #7730 which is basically that:
mhegazy commentedon Oct 30, 2016
this should be handled correctelly when #11929 is merged in.
mhegazy commentedon Oct 30, 2016
closing in favor of #7730.
akarzazi commentedon Oct 30, 2016
My bad, TypeScript seems to handle index notation fine as long as the parameter is a string literal !