@enact/core
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -5,2 +5,8 @@ # Change Log | ||
## [2.2.2] - 2018-10-15 | ||
### Fixed | ||
- `core/util.Job` to cancel existing scheduled `idle()` jobs before scheduling another | ||
## [2.2.1] - 2018-10-09 | ||
@@ -7,0 +13,0 @@ |
{ | ||
"name": "@enact/core", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -187,14 +187,14 @@ "use strict"; | ||
if (typeof window !== 'undefined') { | ||
if (window.requestIdleCallback) { | ||
_this.type = 'idle'; | ||
_this.id = window.requestIdleCallback(function () { | ||
return _this.run(args); | ||
}, { | ||
timeout: timeout | ||
}); | ||
} else { | ||
// If requestIdleCallback is not supported just run the function immediately | ||
_this.fn.apply(_this, args); | ||
} | ||
if (typeof window !== 'undefined' && window.requestIdleCallback) { | ||
_this.stop(); | ||
_this.type = 'idle'; | ||
_this.id = window.requestIdleCallback(function () { | ||
return _this.run(args); | ||
}, { | ||
timeout: timeout | ||
}); | ||
} else { | ||
// since we can't request an idle callback, just pass to startAfter() | ||
_this.startAfter.apply(_this, [timeout].concat(args)); | ||
} | ||
@@ -201,0 +201,0 @@ } |
@@ -82,2 +82,18 @@ "use strict"; | ||
describe('#idle', function () { | ||
// polyfill for PhantomJS to verify expected idle behavior as much as possible | ||
var windowRequest = window.requestIdleCallback; | ||
var windowCancel = window.cancelIdleCallback; | ||
before(function () { | ||
window.requestIdleCallback = windowRequest || function (fn) { | ||
return setTimeout(fn, 0); | ||
}; | ||
window.cancelIdleCallback = windowCancel || function (id) { | ||
clearTimeout(id); | ||
}; | ||
}); | ||
after(function () { | ||
window.requestIdleCallback = windowRequest; | ||
window.cancelIdleCallback = windowCancel; | ||
}); | ||
it('should start job', function (done) { | ||
@@ -101,3 +117,16 @@ var j = new _Job.default(done, 10); | ||
}); | ||
it('should clear an existing job id before starting job', function (done) { | ||
var fn = function fn(arg) { | ||
if (arg === 'first') { | ||
done(new Error('First job ran')); | ||
} else { | ||
done(); | ||
} | ||
}; | ||
var j = new _Job.default(fn); | ||
j.idle('first'); | ||
j.idle('second'); | ||
}); | ||
}); | ||
}); |
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
152356
4008