Ticket #12312 (closed bug: invalid)
jQuery's management of the style attribute is lossy when it's re-serialized?
|Reported by:||craig@…||Owned by:|
I'm surprised to learn that jQuery seems to 'stomp' on the style attribute of DOM elements, reconstructing and replacing it from it's own object model whenever its internals seem to need to. This, as opposed to 'ignoring but keeping' style rules that jQuery doesn't know about. For example, if you want to use -webkit-transform in a .css() call, jQuery ignores it. If you stick it in the HTML, and use a plugin like draggable (jQuery UI), the style attribute gets re-written and your non-native styles (ex: transform) are stripped from the style tag of the dragged element.
It seems to me that jQuery core should allow using it's getters/setters (i.e. .css(property, value)) to be used with any key value pair the author wants. This would make jQuery play nice with other style attributes that it doesn't know about (and there are many). Limiting jQuery's object model to only a subset of supported style properties means jQuery doesn't play nice with other libraries that may inject style attributes into the style tag that jQuery will eventually stomp on whenever it positions an element.
To see what I mean, put style='-moz-transform: rotate(30deg)' on a div and drag it using draggable, or simply use code to trigger a jQuery positioning, like: myDiv.css('position', 'relative') - and you'll see that the -moz-transform was removed from the DOM, presumably because the style attribute was re-serialized using only native jQuery familiar style rules.
I think that when jQuery builds it's object model internally for the style attribute, and rewrites it to the element (serializes it), it should just blindly keep any style attributes that it doesn't know about and assume there's something else in the document that does in fast know about it.
This seems to create a dire choice between using jQuery in a project, or some CSS3 style attributes - both not both. What a terrible choice that is to have to make.
- Status changed from new to closed
- Resolution set to invalid