Loading ...
Sorry, an error occurred while loading the content.

Re: Batik doesn't allow adding JavaScript properties to node objects

Expand Messages
  • th_w@ymail.com
    Hi Cameron, ... Yes, I find them convenient, too (that s why I posted). Bit now that I m aware of the problems they have I ll certainly be more careful with
    Message 1 of 11 , Nov 4, 2009
    • 0 Attachment
      Hi Cameron,

      --- In svg-developers@yahoogroups.com, Cameron McCormack <cam@...> wrote:
      >
      > th_w@...:
      > >
      > > This all makes me wonder whether expando properties are so good after
      > > all.
      >
      > I like them. :-) I think allowing properties that don’t clash to be set
      > on host objects should be required, since that behaviour would be more
      > in line with how native objects operate.
      >

      Yes, I find them convenient, too (that's why I posted). Bit now that I'm aware of the problems they have I'll certainly be more careful with them.

      > > User defined properties might e.g. cause collisions if the object's
      > > native property set might be extended in future versions.
      >
      > Yes, that’s one downside. Picking a property name that starts with,
      > say, an underscore seems relatively safe though.

      I think it would be quite nice if the node object had a subobject that the user can mess with without worries, like

      nodeObject.userProps.myProperty = "something"

      Anyway, attaching properties directly to the object is still easiest to read and write.

      >
      > > I guess this might be the reasoning behind the setUserData features.
      >
      > I think setUserData() exists because the DOM is meant to be language
      > binding agnostic, and in some (most?) other languages, like Java, you
      > can’t extend them with arbitrary properties. So it was added to allow
      > arbitrary key/value pairs to be associated with Nodes.
      >

      Ah, I see - of course. Cameron, thank you very much for this very informative course on JavaScript and the DOM! It's great to have people around who care to share their expertise.

      Thomas W.
    Your message has been successfully submitted and would be delivered to recipients shortly.