Opened 12 years ago
Closed 12 years ago
#8517 closed defect (fixed)
dojo.addClass: check if classStr provided
Reported by: | Les | Owned by: | anonymous |
---|---|---|---|
Priority: | high | Milestone: | 1.3 |
Component: | General | Version: | 1.2.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
I noticed that dojo.addClass, removeClass... don't check if the classStr parameter was provided.
If, for example, I add an undefined classStr to a tree icon node, the iconNode.className property will appear as "dijitInline dijitTreeIcon TreeIconReport? undefined".
I think, it would be better if in this example the 'undefined' class name was not added.
Change History (4)
comment:1 follow-up: 2 Changed 12 years ago by
comment:2 Changed 12 years ago by
This would happen if the user overridden functions getIconClass() or getLabelClass() didn't return a value (class string). So perhaps the Tree code could be modified to compensate for the lack of returned value in these functions, see below:
this._iconClass = tree.getIconClass(item, this.isExpanded) || ''; this._labelClass = tree.getLabelClass(item, this.isExpanded) || '';
comment:3 Changed 12 years ago by
comment:4 Changed 12 years ago by
Milestone: | tbd → 1.3 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
classStr is a required parameter. The developer should ensure defined values are being passed, as bill handled in [16504]. I don't think the extra few bytes in base would be worthwhile here, but please reopen if strongly opposed.
I've noticed this too but it seems like a bug in the Tree code. Isn't calling dojo.addClass() without a class an error? It's not an optional parameter.