[webkit-dev] New approach for DOM attributes that reflect content attributes

Eric Seidel eric at webkit.org
Sun Jun 21 23:08:12 PDT 2009


I think this is great!

I'm a bit confused by this though:

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;

Why a special case for absolute URL conversions?
Should we have a more generic [ReflectFitler=completeURL] syntax?
Do we have enough url-values where this special attribute makes sense
or should src() just be a small wrapper around getAttribute("src")
which knows how to make it absolute?

-eric

On Sun, Jun 21, 2009 at 10:26 PM, Darin Adler<darin at apple.com> wrote:
> 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
>
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>


More information about the webkit-dev mailing list