selection based on DOM Level 3 userData

Hi there,

We came up here with a few cases where we'd love to be able to
select elements based on the userData attached to an element [1].
Of course, this would make sense in CSS only for types that can
be casted into a string. Such a selector makes sense because it
allows to select elements based on data not present in the document
tree. In other terms, and if you have my editor background in mind,
this could allow to dynamically style a document without changing
anything in the document tree... VERY useful when you have to
serialize that tree from time to time...

We have two different suggestions:

1. use a new functional pseudo-notation with tests

    :user-data(key="val)
    :user-data(key~="val)
    :user-data(key|="val)
    :user-data(key^="val)
    :user-data(key$="val)
    :user-data(key*="val)


2. or reuse the attribute selector notation (preferred)

    [user-data(key)="val]
    [user-data(key)~="val]
    [user-data(key)|="val]
    [user-data(key)^="val]
    [user-data(key)$="val]
    [user-data(key)*="val]

    in that case, the backwards-compatible parsing is not a problem
    since the tokenizer will detect a FUNCTION that is normally illegal
    here in attribute selectors. I find this one rather cool, because it
    reuses the attribute selectors that people start to use, it's
    backwards compatible, and it will allow implementors to reuse the
    string matching codes they already implemented for attribute
    selectors.

[1] 
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-setUserData

</Daniel>

Received on Tuesday, 4 March 2008 14:03:49 UTC