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

Commit

Permalink
feat(patch): fix #833, add IntersectionObserver support (#880)
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion authored and mhevery committed Aug 23, 2017
1 parent b1e5970 commit f27ff14
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Zone.__load_patch('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate
}
patchClass('MutationObserver');
patchClass('WebKitMutationObserver');
patchClass('IntersectionObserver');
patchClass('FileReader');
});

Expand Down
18 changes: 18 additions & 0 deletions test/browser/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,24 @@ describe('Zone', function() {
}));
});

it('IntersectionObserver should run callback in zone',
ifEnvSupportsWithDone('IntersectionObserver', (done: Function) => {
const div = document.createElement('div');
const options: any = {root: div, rootMargin: '0px', threshold: 0};

const zone = Zone.current.fork({name: 'intersectionObserverZone'});

zone.run(() => {
const observer = new IntersectionObserver(() => {
expect(Zone.current.name).toEqual(zone.name);
observer.unobserve(div);
done();
}, options);
observer.observe(div);
});
document.body.appendChild(div);
}));

it('HTMLCanvasElement.toBlob should be a ZoneAware MacroTask',
ifEnvSupportsWithDone(supportCanvasTest, (done: Function) => {
const canvas = document.createElement('canvas');
Expand Down

0 comments on commit f27ff14

Please sign in to comment.