Allow 0 params for upgradeDomInternal

upgradeDomInternal now can be called with 0 parameters. In this case it
will go through all registered components, attempt to find any instances
of each, and upgrade them all.
master
Jason Mayes 2015-02-15 00:59:08 +00:00
parent 307f035d0c
commit 5c39b43b3d
1 changed files with 15 additions and 8 deletions

View File

@ -47,16 +47,23 @@ var componentHandler = (function() {
* will have.
*/
function upgradeDomInternal(jsClass, cssClass) {
if (cssClass === undefined) {
var registeredClass = findRegisteredClass_(jsClass);
if (registeredClass) {
cssClass = registeredClass.cssClass;
if (jsClass === undefined && cssClass === undefined) {
for (var i = 0; i < registeredComponents_.length; i++) {
upgradeDomInternal(registeredComponents_[i].className,
registeredComponents_[i].cssClass);
}
} else {
if (cssClass === undefined) {
var registeredClass = findRegisteredClass_(jsClass);
if (registeredClass) {
cssClass = registeredClass.cssClass;
}
}
}
var elements = document.querySelectorAll('.' + cssClass);
for (var n = 0; n < elements.length; n++) {
upgradeElementInternal(elements[n], jsClass);
var elements = document.querySelectorAll('.' + cssClass);
for (var n = 0; n < elements.length; n++) {
upgradeElementInternal(elements[n], jsClass);
}
}
}