Re: Proposal for "Cascading Attribute Sheets" - like CSS, but for attributes!

On 22.8.2012 1:13, Tab Atkins Jr. wrote:
> On Tue, Aug 21, 2012 at 4:07 PM, Glenn Maynard <glenn@zewt.org> wrote:
>> FWIW, while I don't find the idea of attaching event listeners this way too
>> interesting (maybe I could be convinced, but event capturing is already
>> convenient for most of these examples), being able to say "#myform input {
>> autocomplete: off; autocorrect: off; autocapitalize: off; }" or "a { rel:
>> noreferrer; }" would be great.
>>
>> Having it not apply changes dynamically seems weird, since it looks and
>> feels like CSS.  It'd mean these two things--which look intuitively the
>> same, and behave the same with CSS--would be very different when parentNode
>> is in the document:
>>
>> var div = createMyDiv();
>> parentNode.appendChild(div); // our attributes are applied
>> div.className = "foo"; // and we override them
>>
>> var div = createMyDiv();
>> div.className = "foo"; // we set an attribute
>> parentNode.appendChild(div); // and it gets overwritten
>>
>> Also, the behavior of the latter is different depending on whether
>> parentNode is within a document or not, so it's now also dependent on
>> whether, for example, "document.documentElement.appendChild(parentNode)"
>> happens before or after.
> Actually, the two should be identical, because CAS is applied as a
> mutation observer, rather than synchronously.  As long as those
> statements appear in the same microtask, they'll have the same
> behavior regardless of order (CAS will always get to override them).
>
> ~TJ
>
Which does not correspond to CSS behavior and may be cofusing, any 
changes would require something like

var div = createMyDiv();
parentNode.appendChild(div);
setTimeout(function(div) {div.className = 'foo';}, 0, div);
that's weird.

How about this: element is created with all attributes marked as clean, 
any settings (input.value = 5; input.setAttribute('value', 5); delete 
input.value; input.removeAttribute('value')) would mark such property as 
dirty, and inserting new element into DOM would trigger task, that would 
set up all properties based on DOM document's CAS except dirty ones. In 
such case, no ambiguity would occure.

Browsers are able to do it for CSS, should be able to do it for CAS

Brona.




-- 

s pozdravem
          Bronislav Klučka


http://www.bauglir.com <http://www.bauglir.com>

http://www.bauglir.com
Bronislav.Klucka@bauglir.com  <mailto:Bronislav.Klucka@bauglir.com>

   * webové aplikace
   * software na zakázku

Received on Wednesday, 22 August 2012 16:20:50 UTC