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

Commit

Permalink
fix(PatchClass): copy static properties
Browse files Browse the repository at this point in the history
fixes #127
  • Loading branch information
vicb committed Jun 1, 2015
1 parent 08c7084 commit b91f8fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,13 @@ function patchClass(className) {
});
}
}(prop));
};
}

for (prop in OriginalClass) {
if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) {
global[className][prop] = OriginalClass[prop];
}
}
};

module.exports = {
Expand Down
11 changes: 9 additions & 2 deletions test/patch/XMLHttpRequest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ describe('XMLHttpRequest', function () {
req.send();
});

var supportsOnProgress = function() {
var supportsOnProgress = function() {
return 'onprogress' in new XMLHttpRequest();
}
supportsOnProgress.message = "XMLHttpRequest.onprogress";

describe('onprogress', ifEnvSupports(supportsOnProgress, function () {
it('should work with onprogress', function (done) {
var req;
Expand All @@ -52,5 +52,12 @@ describe('XMLHttpRequest', function () {
expect(req.responseType).toBe('document');
});

it('should preserve static constants', function() {
expect(XMLHttpRequest.UNSENT).toEqual(0);
expect(XMLHttpRequest.OPENED).toEqual(1);
expect(XMLHttpRequest.HEADERS_RECEIVED).toEqual(2);
expect(XMLHttpRequest.LOADING).toEqual(3);
expect(XMLHttpRequest.DONE).toEqual(4);
});
});

0 comments on commit b91f8fe

Please sign in to comment.