[whatwg] CSSElementMap - updates needed for out-of-document elements

Ian Hickson ian at hixie.ch
Thu Apr 28 15:02:43 PDT 2011

On Thu, 16 Dec 2010, Tab Atkins Jr. wrote:
> The CSSElementMap object defined in 
> <http://www.whatwg.org/specs/web-apps/current-work/complete/dom.html#dom-document-csselementmap> 
> allows an author to map an element to an identifier that CSS can then 
> use to refer to the element.  However, it allows elements that are 
> outside the DOM tree to be mapped, which creates a problem for CSS - CSS 
> has no notion of elements outside the element-tree.
> We want to preserve this ability, so authors can, for example, generate 
> <canvas> in script, map it to an identifier, and then refer to it with 
> the element() function to provide an animated background for an element.
> While you can put any element in the map, only a subset of them make 
> sense to expose to CSS while out of the DOM.  Particularly, we want to 
> only expose the <img>, <video>, and <canvas> elements, as they have an 
> intrinsic notion of "size" that doesn't rely on layout information.
> So, amendments:
> 1. While any element can be in the CSSElementMap, only elements are 
> either (a) in the DOM or (b) <img>, <video>, or <canvas> outside the DOM 
> are exposed as CSS Element Reference Identifiers.

Done, though I think it would make more sense for this to be in the CSS 
spec, because otherwise every time we support new elements in CSS we have 
to modify the HTML spec as well.

> 2. <img>, <video>, and <canvas>, while outside the DOM, expose the 
> intrinsic width of their content as the size of their margin box. (The 
> margin box of the element is used in the description for element() to 
> figure out how large the generated image should be.)

This seems like something CSS should define. HTML shouldn't need to define 
CSS terms like margin box. This can be defined in CSS generically without 
referencing HTML by just saying that an element not in a document has a 
margin box equal to its intrinsic dimensions, or whatnot.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list