Change Element.style using javascript object
Reported by
annamala...@gmail.com,
Nov 5 2016
|
|||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
Steps to reproduce the problem:
1. Open the attached file
2. See the console
3.
What is the expected behavior?
What went wrong?
In detail ,
I have an HTML element with some inline styles set , then when query
Element.offsetHeight --> it logs correctly
Then when try to manipulate Element.style using javascript object,
It totally unsets style attribute , eg.,
Element.style = {
height : '500px'
}
Then if I again query for height ,
Element.offsetHeight --> it logs 0
I expect setting Element.style with a js object should fail silently , and should log element's height
Safari's behaviour seems correct
Did this work before? N/A
Does this work in other browsers? No
In Firefox and Chrome , it logs 200,0
And in Safari 200,200
Chrome version: 54.0.2840.71 Channel: stable
OS Version: OS X 10.11.6
Flash Version: Shockwave Flash 23.0 r0
,
Nov 8 2016
Someone should double-check but AFAIK this is WAI. The style attribute on Element has [PutForwards=cssText] in the CSSOM spec and cssText is of DOMString type, so we'll serialize the object to "[object Object]", which has no valid declarations in it.
,
Nov 8 2016
The spec says style property (https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style#Setting_style) is read-only , so setting any value should silently fail. Both Safari and IE , logs 200,200 . It seems correct to me , Open for discussion ! Thx
,
Nov 9 2016
This behavior introduced in https://chromium.googlesource.com/chromium/src/+/d1a7b0cbd0a511459f0f6202dfe61e27aa47df46
,
Nov 9 2016
,
Nov 9 2016
The spec here (https://drafts.csswg.org/cssom/#cssstylerule) corroborates #2. The spec OP links to in #4 seems outdated (last updated Nov 2000.) Also FF logs the same as us: First:: 200 Second:: 0 Leaning towards WontFix. Filing a bug on WebKit. Will post the link here when done.
,
Nov 9 2016
,
Nov 9 2016
I didn't know , it forwards to cssText. Thanks ! I thought this is similar to operation like setting navigator.userAgent (which fails silently) |
|||
►
Sign in to add a comment |
|||
Comment 1 by patricia...@chromium.org
, Nov 8 2016Labels: OS-Chrome OS-Linux OS-Windows