Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

reup fix for ticket 2527949 #164

Closed
wants to merge 2 commits into from

3 participants

@davglass davglass was assigned
@triptych

Hi @redbat I wanted to update you on the status of this pull request. @davglass has this on his plate, but the merge process will be complicated, so he's planning to get to it but has not yet had time to pull it in. We're sorry for the delay, and I'll keep you posted on the status if I hear anything new.

@davglass
Owner

I tried pulling this in, but it's so old that the code underneath is way different than it was in the beginning. I'm closing this for now, but I will leave the main bug open for a Loader refactor that's coming soon.

@davglass davglass closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 14, 2012
  1. @redbat

    ticket #2527949

    redbat authored
  2. @redbat

    changed comparison to ===

    redbat authored
This page is out of date. Refresh to see the latest.
View
15 src/loader/js/loader.js
@@ -408,6 +408,16 @@ Y.Loader = function(o) {
// map of modules with a hash of modules that meet the requirement
// self.provides = {};
+ /**
+ * Specify whether or not to load optional dependencies for
+ * a specific modules.
+ * ex. {"history-html5":false, "autocomplete-sources":true}
+ * Overrides loadOptional.
+ * @property loadOptionalCfg
+ * @type {string:boolean}
+ */
+ self.loadOptionalCfg = {};
+
self.config = o;
self._internal = true;
@@ -1377,7 +1387,7 @@ Y.Loader.prototype = {
intl = mod.lang || mod.intl,
info = this.moduleInfo,
ftests = Y.Features && Y.Features.tests.load,
- hash, reparse;
+ hash, reparse, isLoadOptional;
// console.log(name);
@@ -1464,7 +1474,8 @@ Y.Loader.prototype = {
}
}
- if (o && this.loadOptional) {
+ isLoadOptional = (this.loadOptionalCfg[name] === undefined)? this.loadOptional: this.loadOptionalCfg[name];
+ if (o && isLoadOptional) {
for (i = 0; i < o.length; i++) {
if (!hash[o[i]]) {
d.push(o[i]);
View
18 src/loader/tests/loader-tests.js
@@ -1144,6 +1144,24 @@ YUI.add('loader-tests', function(Y) {
Assert.isTrue(out.js[0].indexOf('node-base') > 0, 'Failed to load node-base');
},
+ test_resolve_loadOptional: function() {
+ var loader = new testY.Loader({
+ combine: false,
+ loadOptional: false,
+ loadOptionalCfg: { "autocomplete-sources": false, "dd-plugin": true},
+ require:['autocomplete-sources', "dd-plugin"]
+ });
+ var out = loader.resolve(true);
+ var m = {}
+ for (i in out.js){m[out.js[i].substring(out.js[i].lastIndexOf('/')+1, out.js[i].length)]=i}
+ Assert.isTrue((m['jsonp-min.js'] === undefined)
+ && (m['json-parse-min.js'] === undefined)
+ && (m['io-base-min.js'] === undefined)
+ && (m['yql-min.js'] === undefined)
+ && (m['dd-proxy-min.js'] !== undefined)
+ && (m['dd-constrain-min.js'] !== undefined),
+ 'loadoptionalCfg didn\'t work');
+ },
'test: aliases config option inside group': function() {
var loader = new Y.Loader({
ignoreRegistered: true,
View
84 src/yui/js/load-tests.js
@@ -6,19 +6,8 @@ add('load', '0', {
"trigger": "io-base",
"ua": "nodejs"
});
-// history-hash-ie
-add('load', '1', {
- "name": "history-hash-ie",
- "test": function (Y) {
- var docMode = Y.config.doc && Y.config.doc.documentMode;
-
- return Y.UA.ie && (!('onhashchange' in Y.config.win) ||
- !docMode || docMode < 8);
-},
- "trigger": "history-hash"
-});
// graphics-canvas-default
-add('load', '2', {
+add('load', '1', {
"name": "graphics-canvas-default",
"test": function(Y) {
var DOCUMENT = Y.config.doc,
@@ -30,7 +19,7 @@ add('load', '2', {
"trigger": "graphics"
});
// autocomplete-list-keys
-add('load', '3', {
+add('load', '2', {
"name": "autocomplete-list-keys",
"test": function (Y) {
// Only add keyboard support to autocomplete-list if this doesn't appear to
@@ -49,13 +38,19 @@ add('load', '3', {
"trigger": "autocomplete-list"
});
// dd-gestures
-add('load', '4', {
+add('load', '3', {
"name": "dd-gestures",
"test": function(Y) {
return ((Y.config.win && ("ontouchstart" in Y.config.win)) && !(Y.UA.chrome && Y.UA.chrome < 6));
},
"trigger": "dd-drag"
});
+// scrollview-base-ie
+add('load', '4', {
+ "name": "scrollview-base-ie",
+ "trigger": "scrollview-base",
+ "ua": "ie"
+});
// editor-para-ie
add('load', '5', {
"name": "editor-para-ie",
@@ -63,21 +58,15 @@ add('load', '5', {
"ua": "ie",
"when": "instead"
});
-// transition-timer
+// graphics-vml-default
add('load', '6', {
- "name": "transition-timer",
- "test": function (Y) {
+ "name": "graphics-vml-default",
+ "test": function(Y) {
var DOCUMENT = Y.config.doc,
- node = (DOCUMENT) ? DOCUMENT.documentElement: null,
- ret = true;
-
- if (node && node.style) {
- ret = !('MozTransition' in node.style || 'WebkitTransition' in node.style);
- }
-
- return ret;
+ canvas = DOCUMENT && DOCUMENT.createElement("canvas");
+ return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d")));
},
- "trigger": "transition"
+ "trigger": "graphics"
});
// graphics-svg-default
add('load', '7', {
@@ -92,17 +81,32 @@ add('load', '7', {
},
"trigger": "graphics"
});
-// scrollview-base-ie
+// history-hash-ie
add('load', '8', {
- "name": "scrollview-base-ie",
- "trigger": "scrollview-base",
- "ua": "ie"
+ "name": "history-hash-ie",
+ "test": function (Y) {
+ var docMode = Y.config.doc && Y.config.doc.documentMode;
+
+ return Y.UA.ie && (!('onhashchange' in Y.config.win) ||
+ !docMode || docMode < 8);
+},
+ "trigger": "history-hash"
});
-// widget-base-ie
+// transition-timer
add('load', '9', {
- "name": "widget-base-ie",
- "trigger": "widget-base",
- "ua": "ie"
+ "name": "transition-timer",
+ "test": function (Y) {
+ var DOCUMENT = Y.config.doc,
+ node = (DOCUMENT) ? DOCUMENT.documentElement: null,
+ ret = true;
+
+ if (node && node.style) {
+ ret = !('MozTransition' in node.style || 'WebkitTransition' in node.style);
+ }
+
+ return ret;
+},
+ "trigger": "transition"
});
// dom-style-ie
add('load', '10', {
@@ -168,15 +172,11 @@ add('load', '13', {
},
"trigger": "graphics"
});
-// graphics-vml-default
+// widget-base-ie
add('load', '14', {
- "name": "graphics-vml-default",
- "test": function(Y) {
- var DOCUMENT = Y.config.doc,
- canvas = DOCUMENT && DOCUMENT.createElement("canvas");
- return (DOCUMENT && !DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") && (!canvas || !canvas.getContext || !canvas.getContext("2d")));
-},
- "trigger": "graphics"
+ "name": "widget-base-ie",
+ "trigger": "widget-base",
+ "ua": "ie"
});
// app-transitions-native
add('load', '15', {
Something went wrong with that request. Please try again.