[webkit-dev] New approach for DOM attributes that reflect content attributes
Darin Adler
darin at apple.com
Sun Jun 21 22:26:30 PDT 2009
There are many attributes in the DOM that are simply covers for
getting and setting HTML or SVG attributes. The HTML 5 draft calls
this reflection of content attributes.
Currently we do this by writing getter and setter functions. For
example, see the placeholder and useMap attributes of HTMLInputElement.
A better way to do this is to declare that the attribute reflects a
content attribute in the .idl file, and have the bindings call
setAttribute and getAttribute directly. I plan to do this, with the
following syntax. This indicates that the title attribute reflects a
content attribute named title:
attribute [Reflect] DOMString title;
This indicates that the className DOM attribute reflects a content
attribute named class:
attribute [Reflect=class] DOMString className;
This indicates that the src DOM attribute reflects a content attribute
named src, but that the result is a completed URL, not the raw
attribute value:
attribute [ReflectURL] DOMString src;
I’m going to begin this work with this bug <https://bugs.webkit.org/show_bug.cgi?id=25425
>. That bug talks about a need to change the details of various
getters and setters, and I decided it was better not to do this, but
rather to have the getters and setters be auto-generated.
I will implement this for the JavaScript bindings and Objective-C
bindings, but someone else will have to take care of the V8 bindings.
Once the bindings are working, I plan to remove the functions in the
DOM implementation classes. So I would delete the
HTMLInputElement::placeholder and HTMLInputElement::setPlaceholder
functions once the [Reflect] attribute has been used for them.
For now I will begin by implementing [Reflect] and using it in a few
places, but I won’t delete any functions from the DOM implementation
classes yet.
-- Darin
More information about the webkit-dev
mailing list