-
-
Notifications
You must be signed in to change notification settings - Fork 72
Values are not properly converted to DOMString #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From what I understand, a value is converted to a
https://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
https://heycam.github.io/webidl/#es-type-mapping
https://heycam.github.io/webidl/#es-DOMString I renamed the title of this issue to handle the following cases that were also not handled correctly: target.style.opacity = Symbol('1') // Error
target.style.opacity = { toString: () => [0] } // Error
target.style.opacity = BigInt(1) // '1'
target.style.setProperty('--custom', undefined) // 'undefined'
target.style.setProperty('--custom', true) // 'true'
target.style.setProperty('--custom', { toString: () => null }) // 'null' |
To summarize this issue (continuing discussion from #190 (comment)): In browsers, document.body.style.backgroundColor = { toString() { return "blue"; } };
document.body.style.backgroundColor; // "blue"
document.body.style.opacity = { toString() { return 1; } };
document.body.style.opacity; // "1" In cssstyle, this doesn't work as expected. Full conversion in the style of #116 or #140 is one way to fix this. However given low maintainer bandwidth for this repository those kind of large rewrites have not been reviewable in the past. (See latest discussion at #140 (comment) .) So a quick fix for this and/or #189 and #190 might be simpler. |
Added failing tests based on this issue |
I'm not sure that the following behavior tested in Chrome and Firefox is described in any specification:
Ie. the value should be converted to String if it has a
toString()
method.cssstyle
currently returns''
for all cases, ie. it results to an invalid value. Chrome and Firefox throw an error for case 3.The text was updated successfully, but these errors were encountered: