[Html-widget] attributes

Carl Franks fireartist at gmail.com
Fri Sep 22 16:23:16 CEST 2006


On 22/09/06, A. Pagaltzis <pagaltzis at gmx.de> wrote:
> * Carl Franks <fireartist at gmail.com> [2006-09-22 14:50]:
> > Setting attributes in this way overwrites on the current
> > attributes hash, and wipes out the 'size' which internally is
> > saved as an attribute. Not good.
>
> So save `size` beforehand and wedge it back in after assigning
> the new hash.

I'm worried about breaking backward compatability.
Should the current behaviour be considered a bug, and we add a new
method to explicitly delete the current attributes?

> > If multiple values are passed to attributes(), rather than a
> > hash-ref, add them to the current attributes hash.
>
> That's what I would propose. I find the behaviour of `attributes`
> surprising and very inconvenient anyway.
>
> I can't imagine many cases where I want to replace all attributes
> whereas I want to add a single attribute to a tag *all the time*.
> Both things are doable manually: you can fetch the hash and then
> either set particular (sets of) keys on it or clear it; hence the
> method should provide a shortcut to the common operation, rather
> than to the rare one.
>
> > However, I think
> > attributes( disabled => 'disabled' );
> > is too close, visually, to
> > attributes( { disabled => 'disabled' } );
>
> The best option would probably be a new method. The only problem
> is that the obvious name is taken so any new names will be poorly
> Huffmanized…

add_attributes()
It's not great, I admit...

> > Add AUTOLOAD to HTML::Widget::Accessor, and make sure
> > HTML::Widget::Accessor is always last in the inheritance chain.
>
> Noooooooooooooo… no! No magic, pretty pretty please.

Deal. ;)

Thanks,
Carl



More information about the Html-widget mailing list