- Hi Cameron,
--- In firstname.lastname@example.org, Cameron McCormack <cam@...> wrote:
> > 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.