#117 ✓resolved
MadRabbit

Element#set

Reported by MadRabbit | November 19th, 2009 @ 07:02 PM | in 1.5.0 Release

Element#set doesn't work with some properties case it accesses them as properties not as attributes

Comments and changes to this ticket

  • MadRabbit

    MadRabbit November 22nd, 2009 @ 07:45 PM

    • State changed from “new” to “resolved”

    Following the less-surprize principle I've made this method to set the actual attributes directly via the 'setAttribute' method.

    NOTE: now it won't set unsupported attributes, like say if you try to assign a 'name' to a DIV element or something like that. So in case if you need to assign some custom properties of yours, you'll have to assign them manually to the instance, not through the 'set' method or the constructor.

    The only exception is the TEXTAREA.value property, in order to support textareas simultaneously with any other input element, the 'set' method will assign its value as a property not as an attribute.

  • MadRabbit

    MadRabbit November 24th, 2009 @ 12:00 PM

    • State changed from “resolved” to “open”

    gotta support custom attributes as it was before

  • MadRabbit

    MadRabbit November 24th, 2009 @ 12:04 PM

    • State changed from “open” to “resolved”

    Ticket revisited,

    Evidently the attributes that are not supported as properties does not exist on an element instance, so I used this fact for this case, like that

    for (var key in hash) {
      if (this[key] === undefined)
        this.setAttribute(key, ''+hash[key]);
      
      this[key] = hash[key];
    }
    

    This way it works both with normal and custom attributes, handles standard attributes that are not available as properties, and it also works faster than previous solution.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

RightJS Core Tickets

Shared Ticket Bins

People watching this ticket

Tags

Pages