Extend HTMLElement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christopher Benson-Manica

    Extend HTMLElement

    How do you extend HTMLElement? Why can't you just do

    HTMLElement.pro totype.foo=func tion() {
    alert( 'foo' );
    }

    I assume HTMLElement belongs to some kind of namespace, but darn if I
    can find anything that tells me anything about it.

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cybers pace.org | don't, I need to know. Flames welcome.
  • Michael Winter

    #2
    Re: Extend HTMLElement

    Christopher Benson-Manica wrote:
    [color=blue]
    > How do you extend HTMLElement? Why can't you just do
    >
    > HTMLElement.pro totype.foo=func tion() {
    > alert( 'foo' );
    > }[/color]

    You can, but only in some user agents. Host objects are not required
    to act like native objects. In some respects, IE is particularly
    restrictive in the way in which it treats host objects to the point of
    being, in my opinion, unreasonable.

    It would be safer to create a function that accepts a reference to an
    element.
    [color=blue]
    > I assume HTMLElement belongs to some kind of namespace, [...][/color]

    In user agents that provide it, it will be a property of the global
    object.

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    Working...