Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
chore: v0.6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Mar 21, 2016
1 parent 84a251f commit 9b3e779
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 14 deletions.
134 changes: 134 additions & 0 deletions dist/async-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};

/******/ // The require function
/******/ function __webpack_require__(moduleId) {

/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;

/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };

/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ // Flag the module as loaded
/******/ module.loaded = true;

/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }


/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;

/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;

/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";

/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports) {

(function () {
var AsyncTestZoneSpec = (function () {
function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) {
this._pendingMicroTasks = false;
this._pendingMacroTasks = false;
this._alreadyErrored = false;
this.runZone = Zone.current;
this._finishCallback = finishCallback;
this._failCallback = failCallback;
this.name = 'asyncTestZone for ' + namePrefix;
}
AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () {
var _this = this;
if (!(this._pendingMicroTasks || this._pendingMacroTasks)) {
// We do this because we would like to catch unhandled rejected promises.
// To do this quickly when there are native promises, we must run using an unwrapped
// promise implementation.
var symbol = Zone.__symbol__;
var NativePromise = window[symbol('Promise')];
if (NativePromise) {
NativePromise.resolve(true)[symbol('then')](function () {
if (!_this._alreadyErrored) {
_this.runZone.run(_this._finishCallback);
}
});
}
else {
// For implementations which do not have nativePromise, use setTimeout(0). This is slower,
// but it also works because Zones will handle errors when rejected promises have no
// listeners after one macrotask.
this.runZone.run(function () {
setTimeout(function () {
if (!_this._alreadyErrored) {
_this._finishCallback();
}
}, 0);
});
}
}
};
// Note - we need to use onInvoke at the moment to call finish when a test is
// fully synchronous. TODO(juliemr): remove this when the logic for
// onHasTask changes and it calls whenever the task queues are dirty.
AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) {
try {
return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source);
}
finally {
this._finishCallbackIfDone();
}
};
AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) {
// Let the parent try to handle the error.
var result = parentZoneDelegate.handleError(targetZone, error);
if (result) {
this._failCallback(error.message ? error.message : 'unknown error');
this._alreadyErrored = true;
}
return false;
};
AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, currentZone, targetZone, task) {
if (task.type == 'macroTask' && task.source == 'setInterval') {
this._failCallback('Cannot use setInterval from within an async zone test.');
return;
}
return delegate.scheduleTask(targetZone, task);
};
AsyncTestZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) {
delegate.hasTask(target, hasTaskState);
if (hasTaskState.change == 'microTask') {
this._pendingMicroTasks = hasTaskState.microTask;
this._finishCallbackIfDone();
}
else if (hasTaskState.change == 'macroTask') {
this._pendingMacroTasks = hasTaskState.macroTask;
this._finishCallbackIfDone();
}
};
return AsyncTestZoneSpec;
}());
// Export the class so that new instances can be created with proper
// constructor params.
Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec;
})();


/***/ }
/******/ ]);
4 changes: 2 additions & 2 deletions dist/long-stack-trace-zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@
var value = descriptor.value;
descriptor = {
get: function () {
return renderLongStackTrace(parentTask.data[creationTrace], delegateGet ? delegateGet.apply(this) : value);
return renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], delegateGet ? delegateGet.apply(this) : value);
}
};
Object.defineProperty(error, 'stack', descriptor);
}
else {
error.stack = renderLongStackTrace(parentTask.data[creationTrace], error.stack);
error.stack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack);
}
}
return parentZoneDelegate.handleError(targetZone, error);
Expand Down
2 changes: 1 addition & 1 deletion dist/long-stack-trace-zone.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 31 additions & 9 deletions dist/zone.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
function clearTask(task) {
return clearNative(task.data.handleId);
}
var setNative = utils_1.patchMethod(window, setName, function () { return function (self, args) {
var setNative = utils_1.patchMethod(window, setName, function (delegate) { return function (self, args) {
if (typeof args[0] === 'function') {
var zone = Zone.current;
var options = {
Expand All @@ -108,12 +108,18 @@
}
else {
// cause an error by calling it directly.
return setNative.apply(window, args);
return delegate.apply(window, args);
}
}; });
var clearNative = utils_1.patchMethod(window, cancelName, function () { return function (self, args) {
var clearNative = utils_1.patchMethod(window, cancelName, function (delegate) { return function (self, args) {
var task = args[0];
task.zone.cancelTask(task);
if (task && typeof task.type == 'string') {
task.zone.cancelTask(task);
}
else {
// cause an error by calling it directly.
delegate.apply(window, args);
}
}; });
}

Expand Down Expand Up @@ -645,7 +651,7 @@
"use strict";
var utils_1 = __webpack_require__(3);
var WTF_ISSUE_555 = 'Anchor,Area,Audio,BR,Base,BaseFont,Body,Button,Canvas,Content,DList,Directory,Div,Embed,FieldSet,Font,Form,Frame,FrameSet,HR,Head,Heading,Html,IFrame,Image,Input,Keygen,LI,Label,Legend,Link,Map,Marquee,Media,Menu,Meta,Meter,Mod,OList,Object,OptGroup,Option,Output,Paragraph,Pre,Progress,Quote,Script,Select,Source,Span,Style,TableCaption,TableCell,TableCol,Table,TableRow,TableSection,TextArea,Title,Track,UList,Unknown,Video';
var NO_EVENT_TARGET = 'ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload'.split(',');
var NO_EVENT_TARGET = 'ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload,IDBRequest,IDBOpenDBRequest,IDBDatabase,IDBTransaction,IDBCursor,DBIndex'.split(',');
var EVENT_TARGET = 'EventTarget';
function eventTargetPatch(_global) {
var apis = [];
Expand Down Expand Up @@ -726,8 +732,14 @@
this.removeEventListener(eventName, this[_prop]);
}
if (typeof fn === 'function') {
this[_prop] = fn;
this.addEventListener(eventName, fn, false);
var wrapFn = function (event) {
var result;
result = fn.apply(this, arguments);
if (result != undefined && !result)
event.preventDefault();
};
this[_prop] = wrapFn;
this.addEventListener(eventName, wrapFn, false);
}
else {
this[_prop] = null;
Expand Down Expand Up @@ -841,7 +853,7 @@
// - When `addEventListener` is called on the global context in strict mode, `this` is undefined
// see https://github.com/angular/zone.js/issues/190
var target = self || _global;
var eventTask = findExistingRegisteredTask(target, handler, eventName, useCapturing, false);
var eventTask = findExistingRegisteredTask(target, handler, eventName, useCapturing, true);
if (eventTask) {
eventTask.zone.cancelTask(eventTask);
}
Expand Down Expand Up @@ -1084,6 +1096,14 @@
utils_1.patchOnProperties(HTMLElement.prototype, eventNames);
}
utils_1.patchOnProperties(XMLHttpRequest.prototype, null);
if (typeof IDBIndex !== 'undefined') {
utils_1.patchOnProperties(IDBIndex.prototype, null);
utils_1.patchOnProperties(IDBRequest.prototype, null);
utils_1.patchOnProperties(IDBOpenDBRequest.prototype, null);
utils_1.patchOnProperties(IDBDatabase.prototype, null);
utils_1.patchOnProperties(IDBTransaction.prototype, null);
utils_1.patchOnProperties(IDBCursor.prototype, null);
}
if (supportsWebSocket) {
utils_1.patchOnProperties(WebSocket.prototype, null);
}
Expand Down Expand Up @@ -1148,7 +1168,7 @@
/* 7 */
/***/ function(module, exports, __webpack_require__) {

"use strict";
/* WEBPACK VAR INJECTION */(function(global) {"use strict";
var utils_1 = __webpack_require__(3);
// we have to patch the instance since the proto is non-configurable
function apply(_global) {
Expand Down Expand Up @@ -1178,9 +1198,11 @@
utils_1.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open']);
return proxySocket;
};
global.WebSocket.prototype = Object.create(WS.prototype, { constructor: { value: WebSocket } });
}
exports.apply = apply;

/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))

/***/ }
/******/ ]);
4 changes: 4 additions & 0 deletions dist/zone.js.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,8 @@ interface MacroTask extends Task {
}
interface EventTask extends Task {
}
/** @internal */
declare type AmbientZone = Zone;
/** @internal */
declare type AmbientZoneDelegate = ZoneDelegate;
declare var Zone: ZoneType;
2 changes: 1 addition & 1 deletion dist/zone.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zone.js",
"version": "0.6.3",
"version": "0.6.5",
"description": "Zones for JavaScript",
"main": "dist/zone-node.js",
"browser": "dist/zone.js",
Expand Down

0 comments on commit 9b3e779

Please sign in to comment.