Permalink
Browse files

Fixes #2531942 - Skinnable gallery modules failed to load CSS files f…

…rom the pattern. Test included. All Loader tests pass.
  • Loading branch information...
1 parent 627673f commit 1979f8e3d502ce564ad92d61881725ed9c164fa3 @davglass davglass committed Mar 26, 2012
Showing with 30 additions and 7 deletions.
  1. +12 −3 src/loader/js/loader.js
  2. +17 −3 src/loader/tests/loader-tests.js
  3. +1 −1 src/yui/js/yui.js
View
15 src/loader/js/loader.js
@@ -881,7 +881,7 @@ Y.Loader.prototype = {
*/
addModule: function(o, name) {
name = name || o.name;
-
+
if (typeof o === 'string') {
o = { name: name, fullpath: o };
}
@@ -921,17 +921,25 @@ Y.Loader.prototype = {
o.supersedes = o.supersedes || o.use;
o.ext = ('ext' in o) ? o.ext : (this._internal) ? false : true;
- o.requires = this.filterRequires(o.requires) || [];
// Handle submodule logic
var subs = o.submodules, i, l, t, sup, s, smod, plugins, plug,
j, langs, packName, supName, flatSup, flatLang, lang, ret,
overrides, skinname, when,
conditions = this.conditions, trigger;
// , existing = this.moduleInfo[name], newr;
-
+
this.moduleInfo[name] = o;
+ o.requires = o.requires || [];
+
+ if (o.skinnable) {
+ skinname = this._addSkin(this.skin.defaultSkin, name);
+ o.requires.unshift(skinname);
+ }
+
+ o.requires = this.filterRequires(o.requires) || [];
+
if (!o.langPack && o.lang) {
langs = YArray(o.lang);
for (j = 0; j < langs.length; j++) {
@@ -944,6 +952,7 @@ Y.Loader.prototype = {
}
}
+
if (subs) {
sup = o.supersedes || [];
l = 0;
View
20 src/loader/tests/loader-tests.js
@@ -876,9 +876,9 @@ YUI.add('loader-tests', function(Y) {
Assert.areSame('plug1/lang/subplug1.js', out.js[1], 'Failed to combine plugin with module path LANG JS');
Assert.areSame('plug1/subplug1.js', out.js[2], 'Failed to combine plugin with module path JS');
Assert.areSame('plug1/subplug2.js', out.js[3], 'Failed to combine plugin with module path JS');
-
- Assert.areSame('plug1/assets/skins/sam/subplug1.css', out.css[0], 'Failed to combine plugin with module path CSS');
- Assert.areSame('plug1/assets/skins/sam/subplug2.css', out.css[1], 'Failed to combine plugin with module path CSS');
+
+ Assert.areSame('plug1/assets/skins/sam/subplug2.css', out.css[0], 'Failed to combine plugin with module path CSS');
+ Assert.areSame('plug1/assets/skins/sam/subplug1.css', out.css[1], 'Failed to combine plugin with module path CSS');
Assert.areEqual(2, out.css.length, 'Failed to skin plugins');
},
test_fullpath_with_combine: function() {
@@ -1089,6 +1089,20 @@ YUI.add('loader-tests', function(Y) {
var out = loader.resolve(true);
Assert.isTrue((out.js[0].indexOf('yui.yahooapis.com') === -1), 'Combo URL should not contain yui.yahooapis.com URL');
Assert.areSame('/combo?2in3.4/2.9.0/build/yui2-foo/yui2-foo-min.js', out.js[0], 'Failed to return combo url for 2in3 module.');
+ },
+ 'test: gallery skinnable': function() {
+ var test = this,
+ links = document.getElementsByTagName('link').length + document.getElementsByTagName('style').length;
+ YUI({
+ gallery: 'gallery-2012.03.23-18-00'
+ }).use('gallery-accordion-horiz-vert', function(Y) {
+
+ var links2 = document.getElementsByTagName('link').length + document.getElementsByTagName('style').length;
+ test.resume(function() {
+ Assert.areEqual((links + 1), links2, 'Failed to load css for gallery module');
+ });
+ });
+ test.wait();
}
});
View
2 src/yui/js/yui.js
@@ -583,7 +583,7 @@ with any configuration info required for the module.
if (instances.hasOwnProperty(i)) {
loader = instances[i].Env._loader;
if (loader) {
- if (!loader.moduleInfo[name]) {
+ if (!loader.moduleInfo[name] || loader.moduleInfo[name].temp) {
loader.addModule(details, name);
}
}

0 comments on commit 1979f8e

Please sign in to comment.