Opened 13 years ago

Closed 12 years ago

#961 closed enhancement (wontfix)

prependclass: test first whether the class isn't yet active

Reported by: Jan831 <jan831@…> Owned by: Bryan Forbes
Priority: high Milestone: 0.9
Component: HTML Version: 0.3
Keywords: Cc:
Blocked By: Blocking:

Description

currently dojo.html.prependClass(node, classStr) prepends classStr to the current Class-attribute of node.

It might be better to have some test first check whether node hasn't already the classStr and remove it in that case, before prepending classStr

it would be in that case like: give an existing class the highest precidence, without having it multiple times in the list of class names

Change History (3)

comment:1 Changed 13 years ago by Jan831 <jan831@…>

adding this extra test, this would be the new function (in src/html.js)

dojo.html.prependClass = function(node, classStr){
	if (dojo.html.hasClass(node, classStr)) {
	  dojo.html.removeClass(node, classStr, false);
	}
	classStr += " " + dojo.html.getClass(node);
	return dojo.html.setClass(node, classStr);
}

comment:2 Changed 13 years ago by dylan

Component: GeneralHTML
Milestone: 0.5
Owner: changed from anonymous to Bryan Forbes

comment:3 Changed 12 years ago by Adam Peller

Resolution: wontfix
Status: newclosed

method does not exist in 0.9

Note: See TracTickets for help on using tickets.