Comparing version 1.15.1 to 1.16.0
@@ -95,3 +95,3 @@ define(["../global", "../has", "./config", "require", "module"], function(global, has, config, require, module){ | ||
major: 1, minor: 15, patch: 1, flag: "", | ||
major: 1, minor: 16, patch: 0, flag: "", | ||
revision: rev ? rev[0] : NaN, | ||
@@ -98,0 +98,0 @@ toString: function(){ |
@@ -311,2 +311,27 @@ define(["./sniff", "./_base/window","./dom", "./dom-style"], | ||
function getBoundingClientRect(/*DomNode*/ node) { | ||
// summary: | ||
// Gets the bounding client rectangle for a dom node. | ||
// node: DOMNode | ||
// This will return the result of node.getBoundingClientRect if node is in the dom, and | ||
// {x:0, y:0, width:0, height:0, top:0, right:0, bottom:0, left:0} if it throws an error or the node is not on the dom | ||
// This will handle when IE throws an error or Edge returns an empty object when node is not on the dom | ||
var retEmpty = { x: 0, y: 0, width: 0, height: 0, top: 0, right: 0, bottom: 0, left: 0 }, | ||
ret; | ||
try { | ||
ret = node.getBoundingClientRect(); | ||
} catch (e) { | ||
// IE throws an Unspecified Error if the node is not in the dom. Handle this by returning an object with 0 values | ||
return retEmpty; | ||
} | ||
// Edge returns an empty object if the node is not in the dom. Handle this by returning an object with 0 values | ||
if (typeof ret.left === "undefined") { return retEmpty; } | ||
return ret; | ||
} | ||
geom.setContentSize = function setContentSize(/*DomNode*/ node, /*Object*/ box, /*Object*/ computedStyle){ | ||
@@ -480,3 +505,3 @@ // summary: | ||
var db = win.body(node.ownerDocument), | ||
ret = node.getBoundingClientRect(); | ||
ret= getBoundingClientRect(node); | ||
ret = {x: ret.left, y: ret.top, w: ret.right - ret.left, h: ret.bottom - ret.top}; | ||
@@ -519,3 +544,3 @@ | ||
var me = geom.getMarginExtents(node, computedStyle || style.getComputedStyle(node)); | ||
var size = node.getBoundingClientRect(); | ||
var size = getBoundingClientRect(node); | ||
return { | ||
@@ -522,0 +547,0 @@ w: (size.right - size.left) + me.w, |
{ | ||
"name": "dojo", | ||
"version": "1.15.1", | ||
"version": "1.16.0", | ||
"directories": { | ||
@@ -14,3 +14,3 @@ "lib": "." | ||
"sinon": "1.12.2", | ||
"dojo": "1.15.1" | ||
"dojo": "1.16.0" | ||
}, | ||
@@ -17,0 +17,0 @@ "main": "main", |
@@ -95,2 +95,45 @@ define([ | ||
"finally": function(callback) { | ||
// summary: | ||
// Add a callback to the promise that will fire whether it | ||
// resolves or rejects. | ||
// description: | ||
// Conforms to ES2018's `Promise.prototype.finally`. | ||
// Add a callback to the promise that will fire whether it | ||
// resolves or rejects. No value is passed to the callback. | ||
// Returns a promise that reflects the state of the original promise, | ||
// with two exceptions: | ||
// - If the callback return a promise, the outer promise will wait | ||
// until the returned promise is resolved, then it will resolve | ||
// with the original value. | ||
// - If the callback throws an exception or returns a promise that | ||
// is rejected (or rejects later), the outer promise will reject | ||
// with the inner promise's rejection reason. | ||
// callback: Function? | ||
// Callback to be invoked when the promise is resolved | ||
// or rejected. Doesn't receive any value. | ||
// returns: dojo/promise/Promise | ||
// Returns a new promise that reflects the state of the original promise, | ||
// with two small exceptions (see description). | ||
// | ||
return this.then(function (value){ | ||
var valueOrPromise = callback(); | ||
if (valueOrPromise && typeof valueOrPromise.then === "function"){ | ||
return valueOrPromise.then(function (){ | ||
return value; | ||
}); | ||
} | ||
return value; | ||
}, function(reason) { | ||
var valueOrPromise = callback(); | ||
if (valueOrPromise && typeof valueOrPromise.then === "function"){ | ||
return valueOrPromise.then(function (){ | ||
throw reason; | ||
}); | ||
} | ||
throw reason; | ||
}); | ||
}, | ||
always: function(callbackOrErrback){ | ||
@@ -97,0 +140,0 @@ // summary: |
@@ -16,3 +16,3 @@ define([ | ||
if(matcher(url, options)){ | ||
return matcher.request.call(null, url, options); | ||
return matcher.request.apply(null, arguments); | ||
} | ||
@@ -19,0 +19,0 @@ } |
@@ -78,4 +78,176 @@ define([ | ||
assert.strictEqual(expectedPromise.traceRejected(), expectedPromise); | ||
}, | ||
'finally() called when deferred already resolved': function () { | ||
var deferred = new Deferred(); | ||
var thenExpected = {}; | ||
var finallyExpected = undefined; | ||
deferred.resolve(thenExpected); | ||
return deferred.promise["finally"](function (finallyResult) { | ||
assert.equal(finallyResult, finallyExpected); | ||
return "blah"; | ||
}).then(function (thenResult) { | ||
assert.equal(thenResult, thenExpected); | ||
})["catch"](function () { | ||
assert.fail("Promise should not have rejected."); | ||
}); | ||
}, | ||
'finally() called when deferred is resolved later': function () { | ||
var deferred = new Deferred(); | ||
var thenExpected = {}; | ||
var finallyExpected = undefined; | ||
setTimeout(function () { | ||
deferred.resolve(thenExpected); | ||
},0); | ||
return deferred.promise["finally"](function (finallyResult) { | ||
assert.equal(finallyResult, finallyExpected); | ||
return "blahblah"; | ||
}).then(function (thenResult) { | ||
assert.equal(thenResult, thenExpected); | ||
})["catch"](function () { | ||
assert.fail("Promise should not have rejected."); | ||
}); | ||
}, | ||
'finally() called when deferred already rejected': function () { | ||
var deferred = new Deferred(); | ||
var expected = new Error(); | ||
var finallyExpected = undefined; | ||
deferred.reject(expected); | ||
return deferred.promise["finally"](function (finallyResult) { | ||
assert.equal(finallyResult, finallyExpected); | ||
}).then(function () { | ||
assert.fail("Promise should not have resolved."); | ||
})["catch"](function (result) { | ||
assert.equal(result, expected); | ||
}); | ||
}, | ||
'finally() called when deferred is rejected later': function () { | ||
var deferred = new Deferred(); | ||
var otherwiseExpected = new Error(); | ||
var finallyExpected = undefined; | ||
setTimeout(function () { | ||
deferred.reject(otherwiseExpected); | ||
},0); | ||
return deferred.promise["finally"](function (finallyResult) { | ||
assert.equal(finallyResult, finallyExpected); | ||
}).then(function () { | ||
assert.fail("Promise should not have resolved."); | ||
})["catch"](function (otherwiseResult) { | ||
assert.equal(otherwiseResult, otherwiseExpected); | ||
}); | ||
}, | ||
'finally() holds up call chain when chaining from a resolved promise and returning a promise that will resolve': function () { | ||
var deferred = new Deferred(); | ||
var testValue = 0; | ||
var expectedTestValue = 1; | ||
var thenExpected = {}; | ||
deferred.resolve(thenExpected); | ||
var resultPromise = deferred.promise["finally"](function () { | ||
var dfd2 = new Deferred(); | ||
setTimeout(function () { | ||
testValue = expectedTestValue; | ||
dfd2.resolve({}); | ||
},0); | ||
return dfd2.promise; | ||
}); | ||
//shouldn't be resolved until after the setTimeout fires. | ||
assert.equal(resultPromise.isResolved(), false); | ||
assert.equal(resultPromise.isFulfilled(), false); | ||
return resultPromise.then(function (thenResult) { | ||
assert.equal(testValue, expectedTestValue); | ||
assert.equal(thenResult, thenExpected); | ||
},function () { | ||
assert.fail("Promise should not have rejected"); | ||
}); | ||
}, | ||
'finally() holds up call chain correctly when chaining from a rejected promise and returning a promise that will reject': function () { | ||
var deferred = new Deferred(); | ||
var expectedError = new Error(); | ||
deferred.reject(); | ||
var resultPromise = deferred.promise["finally"](function () { | ||
var dfd2 = new Deferred(); | ||
setTimeout(function () { | ||
dfd2.reject(expectedError); | ||
},0); | ||
return dfd2.promise; | ||
}); | ||
assert.equal(resultPromise.isRejected(), false); | ||
assert.equal(resultPromise.isFulfilled(), false); | ||
return resultPromise.then(function () { | ||
assert.fail("Promise should not have resolved."); | ||
},function (resultError) { | ||
assert.equal(resultError, expectedError); | ||
}); | ||
}, | ||
'finally() returns rejected promise if callback throws exception': function () { | ||
var deferred = new Deferred(); | ||
var expectedError = new Error(); | ||
deferred.resolve(); | ||
return deferred.promise["finally"](function () { | ||
throw expectedError; | ||
}).then(function () { | ||
assert.fail("Promise should not have resolved."); | ||
})["catch"](function (resultError) { | ||
assert.equal(resultError, expectedError); | ||
}); | ||
}, | ||
'finally() returns rejected promise if chained off resolved promise and callback returns rejected promise': function () { | ||
var deferred = new Deferred(); | ||
var expectedError = new Error(); | ||
deferred.resolve(); | ||
return deferred.promise["finally"](function () { | ||
return new Deferred().reject(expectedError); | ||
}).then(function () { | ||
assert.fail("Promise should not have resolved"); | ||
})["catch"](function (resultError) { | ||
assert.equal(resultError, expectedError); | ||
}); | ||
}, | ||
'finally() returns rejected promise if chained off rejected promise and callback returns rejected promise': function () { | ||
var deferred = new Deferred(); | ||
var expectedError = new Error(); | ||
deferred.reject(new Error() /* not the expected error */); | ||
return deferred.promise["finally"](function () { | ||
return new Deferred().reject(expectedError); | ||
}).then(function () { | ||
assert.fail("Promise should not have resolved"); | ||
})["catch"](function (resultError) { | ||
assert.equal(resultError, expectedError); | ||
}); | ||
} | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4658582
138552