[Html-widget] attributes

A. Pagaltzis pagaltzis at gmx.de
Fri Sep 22 16:56:23 CEST 2006

* Carl Franks <fireartist at gmail.com> [2006-09-22 16:30]:
> 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.

Yeah, d’oh. Then only add `size` back in if it doesn’t already
exist in the fresh hash, so that you don’t overwrite explicitly
set values.

> Should the current behaviour be considered a bug, and we add a
> new method to explicitly delete the current attributes?

If you can accept breaking compatibility like that, then I would
say the right course of action is to switch the behaviour from
replacing to merging hashes. After all, the very fact that we’re
having this discussion proves that people find the current
non-merging behaviour surprising.

There is no need for another method if you do so, as I said. You
can already explicitly delete the current attributes:

    %{ $w->attributes } = ( disabled => 'disabled' );

This even documents intent clearly.

Aristotle Pagaltzis // <http://plasmasturm.org/>

More information about the Html-widget mailing list