Skip to content

Commit d859db2

Browse files
committed
using the zones locker instead of the window object
1 parent b4cda14 commit d859db2

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Zones extension (Yozons)
33
*/
44

5+
import * as zones from "./lib/zones.js";
56
import * as section from "./lib/section.js";
67
import * as story from "./lib/story.js";
78

@@ -21,6 +22,9 @@ function distributeZones(locker) {
2122

2223
resolve("zones-loaded")
2324
});
25+
26+
// Set up the communication bridge
27+
locker.getYozonsLocker("zones").changes = zones.changes;
2428
});
2529
}
2630

lib/zones.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
* This class handles individual zone elements
44
*/
55

6-
// Constants for building the vip map and communicating
6+
// Constants for building the vip map
77
const map = new Map();
8-
const changes = new Map();
98
const fragment = new DocumentFragment();
109

10+
// Changes map
11+
export const changes = new Map();
12+
1113
// Zone class
1214
export class Zone {
1315

@@ -231,17 +233,3 @@ export function render() {
231233
map.forEach(zone => zone.inject());
232234
window.dispatchEvent(new Event("zones-loaded"));
233235
}
234-
235-
/*
236-
* Set up the communication bridge
237-
* window.mi.zones isn't available until later
238-
* in the page execution
239-
*/
240-
241-
window.addEventListener("load", () => {
242-
try {
243-
window.mi.zones.changes = changes;
244-
} catch(e) {
245-
console.warn("cannot add changes to the zones object", e);
246-
}
247-
});

0 commit comments

Comments
 (0)