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

Commit 8c854c6

Browse files
vikermanmhevery
authored andcommitted
fix: resolve errors with closure
Also don't patch all "on" properties if a list of properties is being passed in. Otherwise various global variables in window get clobbered. Closes #722
1 parent 7d4d07f commit 8c854c6

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Diff for: lib/browser/property-descriptor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export function propertyDescriptorPatch(_global: any) {
2525
if (isBrowser) {
2626
patchOnProperties(window, eventNames);
2727
patchOnProperties(Document.prototype, eventNames);
28-
if (typeof SVGElement !== 'undefined') {
29-
patchOnProperties(SVGElement.prototype, eventNames);
28+
if (typeof (<any>window)['SVGElement'] !== 'undefined') {
29+
patchOnProperties((<any>window)['SVGElement'].prototype, eventNames);
3030
}
3131
patchOnProperties(HTMLElement.prototype, eventNames);
3232
}

Diff for: lib/common/utils.ts

+10-9
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,20 @@ export function patchProperty(obj: any, prop: string) {
154154
}
155155

156156
export function patchOnProperties(obj: any, properties: string[]) {
157-
const onProperties = [];
158-
for (const prop in obj) {
159-
if (prop.substr(0, 2) == 'on') {
160-
onProperties.push(prop);
161-
}
162-
}
163-
for (let j = 0; j < onProperties.length; j++) {
164-
patchProperty(obj, onProperties[j]);
165-
}
166157
if (properties) {
167158
for (let i = 0; i < properties.length; i++) {
168159
patchProperty(obj, 'on' + properties[i]);
169160
}
161+
} else {
162+
const onProperties = [];
163+
for (const prop in obj) {
164+
if (prop.substr(0, 2) == 'on') {
165+
onProperties.push(prop);
166+
}
167+
}
168+
for (let j = 0; j < onProperties.length; j++) {
169+
patchProperty(obj, onProperties[j]);
170+
}
170171
}
171172
}
172173

0 commit comments

Comments
 (0)