Opened 9 years ago

Last modified 7 years ago

#10634 open enhancement

Introduce dojo.prop as a replacement for dojo.attr

Reported by: James Burke Owned by: Eugene Lazutkin
Priority: high Milestone: 2.0
Component: HTML Version: 1.4.0
Keywords: Cc:
Blocked By: Blocking:

Description

Part of the problem with dojo.attr() is the expectations around what it should do. I believe most uses of it should really use something that favors an object/DOMNode's properties over a DOM node's actual HTML attributes.

I want to see if we can avoid this by introducing a dojo.prop() method, that favors an object's properties. I hopeful this can clear up the confusion about the uses of dojo.attr().

Eugene has explored this area extensively, he can add notes to this ticket as appropriate.

dojo.attr will still need to be supported given back-compat issues.

Change History (4)

comment:1 in reply to:  description Changed 9 years ago by davidmark

Owner: changed from anonymous to davidmark
Status: newassigned

Replying to jburke:

Part of the problem with dojo.attr() is the expectations around what it should do.

Absolutely. That's what I said three to four months ago. The first thing you need to do is define what it is supposed to do (and without redundancy).

It is a very unfortunate name as well.

I believe most uses of it should really use something that favors an object/DOMNode's properties over a DOM node's actual HTML attributes.

There's no choice for the calling app. It does what it does (reads and writes DOM attribute _properties_, occasionally veering off into setting DOM attribute _values_). It is _supposed_ to filter user input and DOM defaults. But that's not the perception or what the docs (or authors) say about it. No wonder there is confusion.

It is used by the parser, as well as all of the Dijit widgets, so this is quite a crisis (like I have been saying for months).

I want to see if we can avoid this by introducing a dojo.prop() method, that favors an object's properties. I hopeful this can clear up the confusion about the uses of dojo.attr().

No, that will further muddy the waters. What will - prop - do? Set DOM attribute values, in contrast to its name? There is already a method to set DOM _property_ values (attr).

Eugene has explored this area extensively, he can add notes to this ticket as appropriate.

He offered some alternate method that didn't make any more sense than the original attr. Perhaps he's been studying the cheat sheet at this point:-

http://www.cinsoft.net/attributes.html

That has both an attr and a prop. As I told Dylan after the refusal to understand in the mailing list, prop is tantamount to what Dojo's attr is _supposed_ to do. The attr method is something that doesn't exist in Dojo at all (and which it sorely needs). That one is supposed to smooth out the get/setAttribute issues. There are dozens of patches throughout Dojo/Dijit?/DojoX that show developers running up against these issues and patching just the bump they encountered. All of that is centralized in the branch in realAttr (named that because attr is already taken).

dojo.attr will still need to be supported given back-compat issues.

That doesn't make any sense. As it sits, dojo.attr is inconsistent across IE versions (let alone other browsers). It won't help anything to do nothing (or to introduce another method that makes no sense). The first step is understanding (for the authors). Then perhaps the users can be enlightened through documentation.

comment:2 Changed 9 years ago by bill

Milestone: 1.52.0
Owner: changed from davidmark to Eugene Lazutkin
Status: assignednew

comment:3 Changed 7 years ago by ben hockey

Status: newopen

comment:4 Changed 7 years ago by bill

Component: CoreHTML
Note: See TracTickets for help on using tickets.