Opened 11 years ago

Closed 11 years ago

#6967 closed defect (wontfix)

Keep custom attributes when rendering widgets

Reported by: wolfram Owned by: wolfram
Priority: high Milestone: 1.3
Component: Dijit Version: 1.1.1
Keywords: Cc: wolfram
Blocked By: Blocking:

Description

<input type="text" dojoType="dijit.form.TextBox?" onkeyup="alert(this.value)" dada="1" />

The "onkeyup" and "dada" attribute is being removed, when this node is rendered as a widget. That is because not the existing attributes are copied but some determined by an attributeMap. That seems wrong. All custom attributes shall be copied. I know the problem is when a widget has a template with some more markup to find out which node to paste the attributes to. But that should just be done by definition.

Change History (7)

comment:1 Changed 11 years ago by bill

It's working currently as designed. Before changing it you'd need to give a better reason that "That seems wrong."

comment:2 Changed 11 years ago by wolfram

"It's working as designed" well then its wrongly designed. To be as expressive.

Is the "keyup" that just doesn't work not reason enough? The widgets just swallow attributes. And that takes away the power of custom attributes. I, sometimes for example add attributes like itemIdText="123" to be able to query for it (can be done with a class too, I know) or the other way around use dojo.attr for it when I have the node. It just seems wrong to take away what the user had put there. Dojo also takes the freedom of using custom attributes like "dojoType", etc. and is lucky that the browser is not insisting on only allowing the attributes it knows. Why does the widget system think it is the only one that knows what attributes are allowed?

Sorry but I think this is the wrong approach to say its good as designed. User comes first, and if he says blue is green or this input has the attribute dada="1" than it may be!

My thoughts ...

comment:3 Changed 11 years ago by wolfram

And by user I don't mean me, I mean the one who puts an attribute there. And it was just me in this case now :-)

comment:4 Changed 11 years ago by wolfram

As Dylan just told me in irc the problem why the current solution is used is that IE reports a lot more attributes than there are actually in there and to optimize the performance an attributeMap was introduced which is a white list of attrributes. So the problem seems to be IE.

comment:5 Changed 11 years ago by bill

The "onkeyup" argument is valid and that will be addressed at some point, see #5417.

Also, if you have a certain custom attribute that you need/want to be copied over, it should be fairly simple to mixin that into _Widget, like:

dojo.extend(dijit._Widget, {
dada: ""
});

and then modify attributeMap to copy it to domNode (or wherever you want it):

dijit._Widget.prototype.attributeMap.dada = "";

As you wrote above, the practical reason we *don't* do this now is that querying every attribute on a node slows down the parser greatly (on IE), because IE sticks in hundreds of implicit attributes to every node which we have to loop through.

As per the philosophical issue that "user comes first" (where user in this case means "developer"), my goal is certainly to give developers a great toolkit that they can use to build a great app, but I don't necessarily want to give a developer a feature just because they asked for it. Practical considerations like performance, code size, etc. take precedence.

comment:6 Changed 11 years ago by bill

Milestone: 1.3
Owner: set to wolfram

Wolfram wants to try a patch for this, so assigning to him. Will consider the patch if it doesn't have performance degradation or excessive code size increase.

comment:7 Changed 11 years ago by bill

Resolution: wontfix
Status: newclosed

Seems there is no way to do this efficiently, so closing bug w/workarounds listed above. Wolfram, reopen if you have a patch.

Note: See TracTickets for help on using tickets.