Closed
Bug 958887
Opened 11 years ago
Closed 10 years ago
Add support for element.style["css-property-name"] non-standard extension
Categories
(Core :: DOM: CSS Object Model, enhancement)
Core
DOM: CSS Object Model
Tracking
()
RESOLVED
FIXED
mozilla35
Tracking | Status | |
---|---|---|
fennec | + | --- |
People
(Reporter: rennie.degraaf, Assigned: bzbarsky)
References
Details
(Keywords: dev-doc-needed, Whiteboard: [parity-IE][parity-webkit][parity-blink])
Attachments
(6 files)
482 bytes,
text/html
|
Details | |
552 bytes,
text/html
|
Details | |
7.82 KB,
patch
|
peterv
:
review+
|
Details | Diff | Splinter Review |
2.75 KB,
patch
|
peterv
:
review+
|
Details | Diff | Splinter Review |
20.33 KB,
patch
|
peterv
:
review+
|
Details | Diff | Splinter Review |
4.86 KB,
patch
|
peterv
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0 (Beta/Release)
Build ID: 20131210132650
Steps to reproduce:
Changing the CSS property background-image via JavaScript does not seem to work in firefox 26.0. It does work in Chromium 27.
The attached test case sets the background-image of a div to a red X, then changes it to a green checkmark using a script. Loading it in Chromium shows the green checkmark; loading it in Firefox shows the red x indicating that the script had no effect. The images used in the test case are SVG, but I got the same result with PNG images.
Setting the background property, rather than the background-image property, works.
Actual results:
Background image did not change.
Expected results:
Background image should have changed.
Comment 1•11 years ago
|
||
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Properties_Reference
Dashes aren't viable for JavaScript property names, so lots of them are different from the name in CSS. Generally, the dashes are dropped and the names are switched to camel-case. The "background-image" JS property is "backgroundImage". I'm surprised style["background-image"] instead of style.backgroundImage works in Chromium.
Updated•11 years ago
|
Summary: Changing background-image with JavaScript doesn't work → Changing element.style["background-image"] with JavaScript doesn't work
Component: Untriaged → JavaScript Engine
OS: Linux → All
Product: Firefox → Core
Hardware: x86_64 → All
Version: 26 Branch → Trunk
Comment 2•11 years ago
|
||
Still invalid per <http://dev.w3.org/csswg/cssom/#cssstyledeclaration>, it seems.
Component: JavaScript Engine → DOM: CSS Object Model
Whiteboard: DUPEME
Comment 3•11 years ago
|
||
related to Bug 947887, Bug 573880 ?
Assignee | ||
Comment 4•11 years ago
|
||
> It does work in Chromium 27.
See http://lists.w3.org/Archives/Public/www-style/2012Feb/0655.html but basically Trident, WebKit, and Blink have a non-standard extensions where in addition to the standardized properties on CSSDeclaration they also implement a bunch of other properties. Gecko and Presto don't do the non-standard bits here.
Of course the only response to my mail was sidetracking by Mr. Adams, about as expected, and in particular no response from anyone at Apple, Google, or Microsoft. So maybe we should just give up, also implement this non-standard extension, and wait for the spec to catch up.
Flags: needinfo?(zcorpan)
Reporter | ||
Comment 5•11 years ago
|
||
Oh. I guess I don't adequately understand the difference between foo.style[prop] and foo.style.getPropertyValue(prop).
Sorry for the entropy, and keep up the good work!
Comment 6•11 years ago
|
||
Flags: needinfo?(zcorpan)
IIRC, WebKit/Blink behavior is also case-insensitive, at least in some places (I think for both the hyphenated and camelCased names, though maybe only the camelCased ones).
Comment 8•11 years ago
|
||
It's not case-insensitive as far as I can tell. http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2732
Assignee | ||
Comment 9•11 years ago
|
||
> Also see https://code.google.com/p/chromium/issues/detail?id=290055
Which is basically being ignored as far as I can tell, right? :(
Assignee | ||
Comment 10•11 years ago
|
||
The main spec issue here, btw, is whether these properties live on the prototype or on the object itself....
Comment 11•11 years ago
|
||
I think there's at least enough desire to mark this bug as an RFE to consider adding this. The JS prop names have always been mildly annoying/confusing and this extension does make some sense.
(In reply to Boris Zbarsky [:bz] from comment #4)
> So maybe we should just give up, also implement this
> non-standard extension, and wait for the spec to catch up.
Is there a bug filed somewhere to add this to spec?
Severity: normal → enhancement
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Changing element.style["background-image"] with JavaScript doesn't work → Add support for element.style["css-property-name"] non-standard extension
Whiteboard: [parity-IE] [parity-webkit] → [parity-IE][parity-webkit][parity-blink]
Assignee | ||
Comment 12•11 years ago
|
||
> Is there a bug filed somewhere to add this to spec?
I haven't filed one.
Comment 13•11 years ago
|
||
(In reply to Boris Zbarsky [:bz] from comment #9)
> Which is basically being ignored as far as I can tell, right? :(
No, it just takes some time to get data from the use counter. It should be available now I think, I've asked davve to have a look.
(In reply to Dave Garrett from comment #11)
> Is there a bug filed somewhere to add this to spec?
There was a thread on www-style and I did add it to the spec, but it's currently commented out in the spec source. There's also https://www.w3.org/Bugs/Public/show_bug.cgi?id=17098
Comment 14•11 years ago
|
||
(In reply to Simon Pieters from comment #8)
> It's not case-insensitive as far as I can tell.
> http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2732
...however, webkitFoo and WebkitFoo both work, and it currently works to mix dashes and uppercase e.g. style['border-rightColor'].
Assignee | ||
Comment 15•11 years ago
|
||
What about in IE?
If we do standardize this, I'd like to standardize the least-insane subset possible, obviously, and 'border-rightColor' is over the boundary. ;)
Updated•11 years ago
|
Comment 16•11 years ago
|
||
IE11 is case-sensitive for camelCase but case-insensitive for dashed properties. Mixing dashes and not dashes is not supported.
In IE, fontSize lives on the prototype but font-size is on the object. In Blink both are on the object (but that might change as part of https://code.google.com/p/chromium/issues/detail?id=43394 - not sure).
The current spec says fontSize should be on the prototype. The commented out spec for dashed properties says they should also be on the prototype, only lowercase is supported and no mixing of dashes and uppercase.
Assignee | ||
Comment 17•11 years ago
|
||
Sounds good. That's the intersection of what Trident and Blink do, so should be reasonable.
Comment 19•11 years ago
|
||
Seems Chrome's usage stats confirm that this is a common problem: https://code.google.com/p/chromium/issues/detail?id=290055#c9 (though some people question whether it is because pages set both hyphenated and camel case - I can't say I've personally noticed scripts doing that..)
Regarding border-rightColor and friends, I suppose what's happening there is some "fallback" algorithm that does a hyphen-to-camel-case conversion if unknown property names with hyphens in are used. While this looks messy from an author point of view, and would indeed be crazy to implement by adding all possible variations to the prototype, I think it would make sense to support this too if it's just adding a couple of lines to an algorithm.
Comment 20•11 years ago
|
||
(In reply to Hallvord R. M. Steen from comment #19)
> Regarding border-rightColor and friends, I suppose what's happening there is
> some "fallback" algorithm that does a hyphen-to-camel-case conversion if
> unknown property names with hyphens in are used. While this looks messy from
> an author point of view, and would indeed be crazy to implement by adding
> all possible variations to the prototype, I think it would make sense to
> support this too if it's just adding a couple of lines to an algorithm.
Mixed forms are no longer supported in Blink. https://code.google.com/p/chromium/issues/detail?id=334562
Comment 21•11 years ago
|
||
That's good news, thank you Simon :-)
Comment 22•11 years ago
|
||
(Note that this breaks Google Images touch UI, might be worth prioritising because we haven't been able to get them to fix it this far..)
Assignee | ||
Comment 23•11 years ago
|
||
Assuming we want to make the change at all, of course.
Comment 24•11 years ago
|
||
FYI https://code.google.com/p/chromium/issues/detail?id=290055 is now WONTFIXed.
Comment 25•11 years ago
|
||
Thanks Simon.
> The consensus on bug 290055 is that we can't drop the corresponding
functionality because of high usage both on the counters and in
libraries.
To me, this suggests we should seriously consider adding support for this (and getting a compat note somewhere in the relevant spec.)
Updated•11 years ago
|
Comment 26•10 years ago
|
||
https://www.w3.org/Bugs/Public/show_bug.cgi?id=17098 - the spec now includes dashed attributes again.
http://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-dashed-attribute
Updated•10 years ago
|
Keywords: dev-doc-needed
Comment 27•10 years ago
|
||
flagging for triage, this would resolve some compatibility problems, such as bug 793216
tracking-e10s:
--- → ?
Yeah, now that this is in the spec, we should do this.
bz/heycam -- how much work does this look like? (I'm not sure whether the wording about what's on the object vs. prototype is hard to do in our webidl setup.)
No idea what it has to do with e10s, though.
Flags: needinfo?(cam)
Flags: needinfo?(bzbarsky)
Comment 29•10 years ago
|
||
Sorry, meant to flag for fennec, not e10s
tracking-fennec: --- → ?
tracking-e10s:
? → ---
Assignee | ||
Comment 30•10 years ago
|
||
> bz/heycam -- how much work does this look like?
I was actually just looking into this. The current spec wording basically treats these properties like any other IDL attribute on the prototype, as far as I can tell.
Implementing that should be pretty simple. Patches coming up in a bit.
Flags: needinfo?(bzbarsky)
Flags: needinfo?(cam)
Assignee | ||
Comment 31•10 years ago
|
||
Attachment #8490243 -
Flags: review?(peterv)
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Assignee | ||
Comment 32•10 years ago
|
||
Attachment #8490244 -
Flags: review?(peterv)
Assignee | ||
Comment 33•10 years ago
|
||
Attachment #8490245 -
Flags: review?(peterv)
Assignee | ||
Comment 34•10 years ago
|
||
Attachment #8490246 -
Flags: review?(peterv)
Assignee | ||
Comment 35•10 years ago
|
||
One note: This implements distinct specialized getters/setters which call the same C++ implementation.
We could try to do something more complicated in codegen where we'd use the specialized getter/setter for the non-dashed version, though the error reporting would look weird. I wasn't sure whether that complexity was really worth it, though admittedly it would avoid the need for most of part 3.
Updated•10 years ago
|
tracking-fennec: ? → +
Updated•10 years ago
|
Attachment #8490243 -
Flags: review?(peterv) → review+
Updated•10 years ago
|
Attachment #8490244 -
Flags: review?(peterv) → review+
Updated•10 years ago
|
Attachment #8490245 -
Flags: review?(peterv) → review+
Updated•10 years ago
|
Attachment #8490246 -
Flags: review?(peterv) → review+
Assignee | ||
Comment 36•10 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/0933d8d6fc10
https://hg.mozilla.org/integration/mozilla-inbound/rev/e3adea0bd276
https://hg.mozilla.org/integration/mozilla-inbound/rev/aeaee069ed50
https://hg.mozilla.org/integration/mozilla-inbound/rev/84e73f166d21
Target Milestone: --- → mozilla35
Comment 37•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/0933d8d6fc10
https://hg.mozilla.org/mozilla-central/rev/e3adea0bd276
https://hg.mozilla.org/mozilla-central/rev/aeaee069ed50
https://hg.mozilla.org/mozilla-central/rev/84e73f166d21
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Updated•10 years ago
|
QA Whiteboard: [good first verify]
You need to log in
before you can comment on or make changes to this bug.
Description
•