From 825b61ddac5c2d203dc125275fb217042a0e9b92 Mon Sep 17 00:00:00 2001 From: Jason Mayes Date: Wed, 11 Mar 2015 10:58:29 +0000 Subject: [PATCH 1/2] Updating correct componentHandler! To take 0 params for upgradeDom. --- src/wskComponentHandler.js | 40 ++++++++++++++------------------------ 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/src/wskComponentHandler.js b/src/wskComponentHandler.js index bbe61173..13196a18 100644 --- a/src/wskComponentHandler.js +++ b/src/wskComponentHandler.js @@ -41,16 +41,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); + } } } @@ -145,20 +152,3 @@ var componentHandler = (function() { register: registerInternal }; })(); - - -window.addEventListener('load', function() { - 'use strict'; - - /** - * Performs a "Cutting the mustard" test. If the browser supports the features - * tested, adds a wsk-js class to the element. It then upgrades all WSK - * components requiring JavaScript. - */ - if ('classList' in document.createElement('div') && 'querySelector' in document && 'addEventListener' in window && Array.prototype.forEach) { - document.documentElement.classList.add('wsk-js'); - componentHandler.upgradeAllRegistered(); - } else { - componentHandler.upgradeElement = componentHandler.register = function () { }; - } -}); From 04b00eeaa1dfab80b6f40b01618a69a239b60617 Mon Sep 17 00:00:00 2001 From: Jason Mayes Date: Wed, 11 Mar 2015 11:02:54 +0000 Subject: [PATCH 2/2] Re adding the mustard test too :-) --- src/wskComponentHandler.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/wskComponentHandler.js b/src/wskComponentHandler.js index 13196a18..db344bf8 100644 --- a/src/wskComponentHandler.js +++ b/src/wskComponentHandler.js @@ -152,3 +152,21 @@ var componentHandler = (function() { register: registerInternal }; })(); + + +window.addEventListener('load', function() { + 'use strict'; + + /** + * Performs a "Cutting the mustard" test. If the browser supports the features + * tested, adds a wsk-js class to the element. It then upgrades all WSK + * components requiring JavaScript. + */ + if ('classList' in document.createElement('div') && 'querySelector' in document && + 'addEventListener' in window && Array.prototype.forEach) { + document.documentElement.classList.add('wsk-js'); + componentHandler.upgradeAllRegistered(); + } else { + componentHandler.upgradeElement = componentHandler.register = function () { }; + } +});