W3C home > Mailing lists > Public > www-style@w3.org > August 2013

RE: [css-om] CSSStyleDeclaration.parentElement

From: François REMY <francois.remy.dev@outlook.com>
Date: Tue, 6 Aug 2013 19:08:33 +0200
Message-ID: <DUB120-W3272D016779B1FB532ED04A55D0@phx.gbl>
To: Simon Pieters <simonp@opera.com>, "www-style@w3.org" <www-style@w3.org>
> Subject: [css-om] CSSStyleDeclaration.parentElement
>> Returns the element that host the current style declaration, if any. {
>> NOTE: This attribute is mutually exclusive with the parentRule
>> attribute, in the sense at most one of the two can return a non-null
>> value. }
>>
>> // would be great to add to the web platform, polyfilling
>> "someNode.style.someProperty" is a huge pain right now...
>
> Can you elaborate on the use case?

I want to fake support for some property. Let's say I want to support "flow-from" from the CSS Regions Spec.

The normal way to do this would be to extend CSSStyleDeclaration and define some "flowFrom" property there. However, if you want to apply this property, you need to have a reference to the element on which this property applies and you have none in the CSSStyleDeclaration interface. { NOTE: you may, for instance, want to update some HTML attribute in response to a change in style. }




My idea to work-around the lack of "parentElement" was then to override HTMLElement.prototype.style and path the "parentElement" property when the style declaration is created but... thank you Webkit for considering "style" as a magic own value property of every element, that's so helpful!

Finally, I settled on a new "myStyle" property which would return the "style" of the element but would add manually the "parentElement" property so that I can access it in my "flowFrom" getter/setter. That's a ugly hack but I can't do better for now... 		 	   		  
Received on Tuesday, 6 August 2013 17:09:05 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:32 UTC