From eade97e57ddfcc6cb5389698fd397e2918689156 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 29 Jun 2019 12:29:29 +0700 Subject: [PATCH] fix(zone.js): __load_patch and __symbol__ should be in zone_extern for closure compiler (#31350) PR Close #31350 --- packages/zone.js/lib/closure/zone_externs.js | 4 ++++ packages/zone.js/lib/zone.ts | 9 +++++++-- packages/zone.js/test/closure/zone.closure.ts | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/zone.js/lib/closure/zone_externs.js b/packages/zone.js/lib/closure/zone_externs.js index 10c8e621f32e6..46183b0e5f9b6 100644 --- a/packages/zone.js/lib/closure/zone_externs.js +++ b/packages/zone.js/lib/closure/zone_externs.js @@ -27,6 +27,10 @@ Zone.prototype.name; Zone.assertZonePatched = function() {}; +Zone.__symbol__ = function(name) {}; + +Zone.__load_patch = function(name, fn) {}; + /** * @type {!Zone} Returns the current [Zone]. Returns the current zone. The only way to change * the current zone is by invoking a run() method, which will update the current zone for the diff --git a/packages/zone.js/lib/zone.ts b/packages/zone.js/lib/zone.ts index c29962998004c..8898656c50e35 100644 --- a/packages/zone.js/lib/zone.ts +++ b/packages/zone.js/lib/zone.ts @@ -309,10 +309,15 @@ interface ZoneType { */ root: Zone; - /** @internal */ + /** + * load patch for specified native module, allow user to + * define their own patch, user can use this API after loading zone.js + */ __load_patch(name: string, fn: _PatchFn): void; - /** Was @ internal but this prevents compiling tests as separate unit */ + /** + * Zone symbol API to generate a string with __zone_symbol__ prefix + */ __symbol__(name: string): string; } diff --git a/packages/zone.js/test/closure/zone.closure.ts b/packages/zone.js/test/closure/zone.closure.ts index 00d0d4214385c..ebdcd7b927dff 100644 --- a/packages/zone.js/test/closure/zone.closure.ts +++ b/packages/zone.js/test/closure/zone.closure.ts @@ -52,6 +52,9 @@ const testClosureFunction = () => { } }; + Zone.__load_patch('test_closure_load_patch', function() {}); + Zone.__symbol__('test_symbol'); + const testZone: Zone = Zone.current.fork(testZoneSpec); testZone.runGuarded(() => { testZone.run(() => {