W3C home > Mailing lists > Public > www-style@w3.org > March 2008

selection based on DOM Level 3 userData

From: Daniel Glazman <daniel.glazman@disruptive-innovations.com>
Date: Tue, 04 Mar 2008 15:03:30 +0100
Message-ID: <47CD56B2.60100@disruptive-innovations.com>
To: "www-style@w3.org" <www-style@w3.org>
Cc: Laurent Jouanneau <laurent.jouanneau@disruptive-innovations.com>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:02 GMT