Skip to content

Commit 69b3548

Browse files
committed
Remove Symbol.observable polyfill
1 parent acb9ed3 commit 69b3548

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zen-observable",
3-
"version": "0.9.0",
3+
"version": "0.10.0",
44
"repository": "zenparsing/zen-observable",
55
"description": "An Implementation of ES Observables",
66
"homepage": "https://github.com/zenparsing/zen-observable",

src/Observable.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
const hasSymbol = name => Boolean(Symbol[name]);
44
const getSymbol = name => hasSymbol(name) ? Symbol[name] : '@@' + name;
55

6-
if (!hasSymbol('observable') && Object.isExtensible(Symbol)) {
7-
Symbol.observable = Symbol('observable');
8-
}
9-
106
const SymbolIterator = getSymbol('iterator');
117
const SymbolObservable = getSymbol('observable');
128
const SymbolSpecies = getSymbol('species');

test/from.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,22 @@ describe('from', () => {
4141
it('wraps the input if it is not an instance of Observable', () => {
4242
let obj = {
4343
'constructor': Observable,
44-
[Symbol.observable]() { return this },
44+
[observableSymbol]() { return this },
45+
};
46+
assert.ok(Observable.from(obj) !== obj);
47+
});
48+
49+
it('uses @@observable as the property name unless polyfilled', () => {
50+
let obj = {
51+
'constructor': Observable,
52+
'@@observable'() { return this },
4553
};
4654
assert.ok(Observable.from(obj) !== obj);
4755
});
4856

4957
it('throws if @@observable property is not a method', () => {
5058
assert.throws(() => Observable.from({
51-
[Symbol.observable]: 1
59+
[observableSymbol]: 1
5260
}));
5361
});
5462

@@ -62,7 +70,7 @@ describe('from', () => {
6270
let observer;
6371
let cleanupCalled = true;
6472
let observable = Observable.from({
65-
[Symbol.observable]() { return inner },
73+
[observableSymbol]() { return inner },
6674
});
6775
observable.subscribe();
6876
assert.equal(typeof observer.next, 'function');

test/setup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ beforeEach(() => {
44
global.Observable = Observable;
55
global.hostError = null;
66
let $extensions = Object.getOwnPropertySymbols(Observable)[1];
7-
let { hostReportError } = Observable[$extensions];
7+
let { hostReportError, symbol } = Observable[$extensions];
88
hostReportError.log = (e => global.hostError = e);
9+
global.observableSymbol = symbol;
910
});

0 commit comments

Comments
 (0)