From 51dafe62e02c4298859ac8f1c5945899241fac23 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sat, 1 Dec 2018 17:24:04 +0100 Subject: fix playgrounds, delete unneeded files --- src/modules/core/event.js | 28 +++++++++++++++++----------- src/utils/adopter.js | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/modules/core/event.js b/src/modules/core/event.js index 507e91f..d9b4f46 100644 --- a/src/modules/core/event.js +++ b/src/modules/core/event.js @@ -3,27 +3,32 @@ import { makeInstance } from '../../utils/adopter.js' import { globals } from '../../utils/window.js' let listenerId = 0 +let windowEvents = {} -function getEvents (node) { - const n = makeInstance(node).getEventHolder() +function getEvents (instance) { + let n = instance.getEventHolder() + + // We dont want to save events in global space + if (n === globals.window) n = windowEvents if (!n.events) n.events = {} return n.events } -function getEventTarget (node) { - return makeInstance(node).getEventTarget() +function getEventTarget (instance) { + return instance.getEventTarget() } -function clearEvents (node) { - const n = makeInstance(node).getEventHolder() +function clearEvents (instance) { + const n = instance.getEventHolder() if (n.events) n.events = {} } // Add event binder in the SVG namespace export function on (node, events, listener, binding, options) { var l = listener.bind(binding || node) - var bag = getEvents(node) - var n = getEventTarget(node) + var instance = makeInstance(node) + var bag = getEvents(instance) + var n = getEventTarget(instance) // events can be an array of events or a string of events events = Array.isArray(events) ? events : events.split(delimiter) @@ -51,8 +56,9 @@ export function on (node, events, listener, binding, options) { // Add event unbinder in the SVG namespace export function off (node, events, listener, options) { - var bag = getEvents(node) - var n = getEventTarget(node) + var instance = makeInstance(node) + var bag = getEvents(instance) + var n = getEventTarget(instance) // listener can be a function or a number if (typeof listener === 'function') { @@ -109,7 +115,7 @@ export function off (node, events, listener, options) { off(n, event) } - clearEvents(node) + clearEvents(instance) } }) } diff --git a/src/utils/adopter.js b/src/utils/adopter.js index 3e86d8a..34b853e 100644 --- a/src/utils/adopter.js +++ b/src/utils/adopter.js @@ -51,7 +51,7 @@ export function adopt (node) { if (node.instance instanceof Base) return node.instance // initialize variables - var className = capitalize(node.nodeName) + var className = capitalize(node.nodeName || 'Dom') // Make sure that gradients are adopted correctly if (className === 'LinearGradient' || className === 'RadialGradient') { -- cgit v1.2.3