Skip to content

Commit f610d15

Browse files
committed
Doc and lib updates
1 parent f6f8df3 commit f610d15

3 files changed

Lines changed: 49 additions & 23 deletions

File tree

docs/preloadjs_docs-NEXT.zip

1.04 KB
Binary file not shown.

lib/preloadjs-NEXT.combined.js

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ this.createjs = this.createjs || {};
5656
* @type {String}
5757
* @static
5858
**/
59-
s.buildDate = /*=date*/"Wed, 11 Jan 2017 23:28:23 GMT"; // injected by build process
59+
s.buildDate = /*=date*/"Thu, 01 Jun 2017 19:45:23 GMT"; // injected by build process
6060

6161
})();
6262

@@ -885,17 +885,15 @@ this.createjs = this.createjs||{};
885885
// private methods:
886886
/**
887887
* @method _dispatchEvent
888-
* @param {Object | String | Event} eventObj
888+
* @param {Object | Event} eventObj
889889
* @param {Object} eventPhase
890890
* @protected
891891
**/
892892
p._dispatchEvent = function(eventObj, eventPhase) {
893-
var l, listeners = (eventPhase==1) ? this._captureListeners : this._listeners;
894-
if (eventObj && listeners) {
895-
var arr = listeners[eventObj.type];
896-
if (!arr||!(l=arr.length)) { return; }
893+
var l, arr, listeners = (eventPhase <= 2) ? this._captureListeners : this._listeners;
894+
if (eventObj && listeners && (arr = listeners[eventObj.type]) && (l=arr.length)) {
897895
try { eventObj.currentTarget = this; } catch (e) {}
898-
try { eventObj.eventPhase = eventPhase; } catch (e) {}
896+
try { eventObj.eventPhase = eventPhase|0; } catch (e) {}
899897
eventObj.removed = false;
900898

901899
arr = arr.slice(); // to avoid issues with items being removed or added during the dispatch
@@ -909,6 +907,7 @@ this.createjs = this.createjs||{};
909907
}
910908
}
911909
}
910+
if (eventPhase === 2) { this._dispatchEvent(eventObj, 2.1); }
912911
};
913912

914913

@@ -3492,11 +3491,13 @@ this.createjs = this.createjs || {};
34923491
case "complete":
34933492
this._rawResult = event.target._response;
34943493
var result = this.resultFormatter && this.resultFormatter(this);
3494+
// The resultFormatter is asynchronous
34953495
if (result instanceof Function) {
34963496
result.call(this,
34973497
createjs.proxy(this._resultFormatSuccess, this),
34983498
createjs.proxy(this._resultFormatFailed, this)
34993499
);
3500+
// The result formatter is synchronous
35003501
} else {
35013502
this._result = result || this._rawResult;
35023503
this._sendComplete();
@@ -4273,6 +4274,9 @@ this.createjs = this.createjs || {};
42734274
/**
42744275
* The XHR request has completed. This is called by the XHR request directly, or by a readyStateChange that has
42754276
* <code>request.readyState == 4</code>. Only the first call to this method will be processed.
4277+
*
4278+
* Note that This method uses {{#crossLink "_checkError"}}{{/crossLink}} to determine if the server has returned an
4279+
* error code.
42764280
* @method _handleLoad
42774281
* @param {Object} event The XHR load event.
42784282
* @private
@@ -4324,16 +4328,25 @@ this.createjs = this.createjs || {};
43244328

43254329
// Protected
43264330
/**
4327-
* Determine if there is an error in the current load. This checks the status of the request for problem codes. Note
4328-
* that this does not check for an actual response. Currently, it only checks for error codes between 400 and 599
4331+
* Determine if there is an error in the current load.
4332+
* Currently this checks the status of the request for problem codes, and not actual response content:
4333+
* <ul>
4334+
* <li>Status codes between 400 and 599 (HTTP error range)</li>
4335+
* <li>A status of 0, but *only when the application is running on a server*. If the application is running
4336+
* on `file:`, then it may incorrectly treat an error on local (or embedded applications) as a successful
4337+
* load.</li>
4338+
* </ul>
43294339
* @method _checkError
4330-
* @return {int} If the request status returns an error code.
4340+
* @return {Error} An error with the status code in the `message` argument.
43314341
* @private
43324342
*/
43334343
p._checkError = function () {
43344344
var status = parseInt(this._request.status);
43354345
if (status >= 400 && status <= 599) {
43364346
return new Error(status);
4347+
} else if (status == 0) {
4348+
if ((/^https?:/).test(location.protocol)) { return new Error(0); }
4349+
return null; // Likely an embedded app.
43374350
} else {
43384351
return null;
43394352
}
@@ -5224,7 +5237,7 @@ this.createjs = this.createjs || {};
52245237
/**
52255238
* This event is fired when an individual file starts to load.
52265239
* @event filestart
5227-
* @param {Object} The object that dispatched the event.
5240+
* @param {Object} target The object that dispatched the event.
52285241
* @param {String} type The event type.
52295242
* @param {Object} item The file item which was specified in the {{#crossLink "LoadQueue/loadFile"}}{{/crossLink}}
52305243
* or {{#crossLink "LoadQueue/loadManifest"}}{{/crossLink}} call. If only a string path or tag was specified, the
@@ -6781,7 +6794,7 @@ this.createjs = this.createjs || {};
67816794
*/
67826795
p._handleTimeout = function () {
67836796
this._stopWatching();
6784-
this.dispatchEvent(new createjs.ErrorEvent("PRELOAD_TIMEOUT", null, event));
6797+
this.dispatchEvent(new createjs.ErrorEvent("PRELOAD_TIMEOUT"));
67856798
};
67866799

67876800
// WatchCSS does the work for us, and provides a modified src.
@@ -7249,10 +7262,12 @@ this.createjs = this.createjs || {};
72497262
} else {
72507263
tag.onload = createjs.proxy(function() {
72517264
successCallback(this._tag);
7265+
tag.onload = tag.onerror = null;
72527266
}, this);
72537267

7254-
tag.onerror = createjs.proxy(function() {
7255-
errorCallback(this._tag);
7268+
tag.onerror = createjs.proxy(function(event) {
7269+
errorCallback(new createjs.ErrorEvent('IMAGE_FORMAT', null, event));
7270+
tag.onload = tag.onerror = null;
72567271
}, this);
72577272
}
72587273
};
@@ -7446,9 +7461,12 @@ this.createjs = this.createjs || {};
74467461
* console.log(json.obj.bool); // true
74477462
* }
74487463
*
7449-
* Note that JSONP files loaded concurrently require a <em>unique</em> callback. To ensure JSONP files are loaded
7450-
* in order, either use the {{#crossLink "LoadQueue/setMaxConnections"}}{{/crossLink}} method (set to 1),
7451-
* or set {{#crossLink "LoadItem/maintainOrder:property"}}{{/crossLink}} on items with the same callback.
7464+
* JSONP files loaded concurrently require a <em>unique</em> callback. To ensure JSONP files are loaded in order,
7465+
* either use the {{#crossLink "LoadQueue/setMaxConnections"}}{{/crossLink}} method (set to 1), or set
7466+
* {{#crossLink "LoadItem/maintainOrder:property"}}{{/crossLink}} on items with the same callback.
7467+
*
7468+
* Important note: Some browsers will prevent JSONP from firing the callback if the file was loaded as JSON, and not
7469+
* JavaScript. You may have to have your server give you a JavaScript mime-type for this to work.
74527470
*
74537471
* @class JSONPLoader
74547472
* @param {LoadItem|Object} loadItem
@@ -7590,13 +7608,16 @@ this.createjs = this.createjs || {};
75907608
* Note that the {{#crossLink "JSONLoader"}}{{/crossLink}} and {{#crossLink "JSONPLoader"}}{{/crossLink}} are
75917609
* higher priority loaders, so manifests <strong>must</strong> set the {{#crossLink "LoadItem"}}{{/crossLink}}
75927610
* {{#crossLink "LoadItem/type:property"}}{{/crossLink}} property to {{#crossLink "AbstractLoader/MANIFEST:property"}}{{/crossLink}}.
7611+
*
7612+
* Additionally, some browsers require the server to serve a JavaScript mime-type for JSONP, so it may not work in
7613+
* some conditions.
75937614
* @class ManifestLoader
75947615
* @param {LoadItem|Object} loadItem
75957616
* @extends AbstractLoader
75967617
* @constructor
75977618
*/
7598-
function ManifestLoader(loadItem) {
7599-
this.AbstractLoader_constructor(loadItem, null, createjs.AbstractLoader.MANIFEST);
7619+
function ManifestLoader(loadItem, preferXHR) {
7620+
this.AbstractLoader_constructor(loadItem, preferXHR, createjs.AbstractLoader.MANIFEST);
76007621

76017622
// Public Properties
76027623
/**
@@ -7693,7 +7714,7 @@ this.createjs = this.createjs || {};
76937714
*/
76947715
p._loadManifest = function (json) {
76957716
if (json && json.manifest) {
7696-
var queue = this._manifestQueue = new createjs.LoadQueue();
7717+
var queue = this._manifestQueue = new createjs.LoadQueue(this._preferXHR);
76977718
queue.on("fileload", this._handleManifestFileLoad, this);
76987719
queue.on("progress", this._handleManifestProgress, this);
76997720
queue.on("complete", this._handleManifestComplete, this, true);
@@ -8134,7 +8155,12 @@ this.createjs = this.createjs || {};
81348155
}
81358156

81368157
if (xml.documentElement != null) {
8137-
tag.appendChild(xml.documentElement);
8158+
var element = xml.documentElement;
8159+
// Support loading an SVG from a different domain in ID
8160+
if (document.importNode) {
8161+
element = document.importNode(element, true);
8162+
}
8163+
tag.appendChild(element);
81388164
return tag;
81398165
} else { // For browsers that don't support SVG, just give them the XML. (IE 9-8)
81408166
return xml;

0 commit comments

Comments
 (0)