diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-13 08:16:12 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-13 08:16:52 +0100 |
commit | b2128609ac8159a14224deba399144b3400c8c20 (patch) | |
tree | 4759dfda67c54f6838c3aef0951545ae18bb83bd /thirdparty/preact/src/dom/index.js | |
parent | 3f0ee289c4a61991d0e75906a9bd949cebb39d20 (diff) | |
download | wallet-core-b2128609ac8159a14224deba399144b3400c8c20.tar.xz |
Finally give in and use React, minor tweeks.
Preact (a minimalistic React alternative) had too many bugs ...
Diffstat (limited to 'thirdparty/preact/src/dom/index.js')
-rw-r--r-- | thirdparty/preact/src/dom/index.js | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/thirdparty/preact/src/dom/index.js b/thirdparty/preact/src/dom/index.js deleted file mode 100644 index b72d056af..000000000 --- a/thirdparty/preact/src/dom/index.js +++ /dev/null @@ -1,99 +0,0 @@ -import { NON_DIMENSION_PROPS, NON_BUBBLING_EVENTS } from '../constants'; -import options from '../options'; -import { toLowerCase, isString, isFunction, hashToClassName } from '../util'; - - - - -/** Removes a given DOM Node from its parent. */ -export function removeNode(node) { - let p = node.parentNode; - if (p) p.removeChild(node); -} - - -/** Set a named attribute on the given Node, with special behavior for some names and event handlers. - * If `value` is `null`, the attribute/handler will be removed. - * @param {Element} node An element to mutate - * @param {string} name The name/key to set, such as an event or attribute name - * @param {any} value An attribute value, such as a function to be used as an event handler - * @param {any} previousValue The last value that was set for this name/node pair - * @private - */ -export function setAccessor(node, name, old, value, isSvg) { - - if (name==='className') name = 'class'; - - if (name==='class' && value && typeof value==='object') { - value = hashToClassName(value); - } - - if (name==='key') { - // ignore - } - else if (name==='class' && !isSvg) { - node.className = value || ''; - } - else if (name==='style') { - if (!value || isString(value) || isString(old)) { - node.style.cssText = value || ''; - } - if (value && typeof value==='object') { - if (!isString(old)) { - for (let i in old) if (!(i in value)) node.style[i] = ''; - } - for (let i in value) { - node.style[i] = typeof value[i]==='number' && !NON_DIMENSION_PROPS[i] ? (value[i]+'px') : value[i]; - } - } - } - else if (name==='dangerouslySetInnerHTML') { - if (value) node.innerHTML = value.__html; - } - else if (name[0]=='o' && name[1]=='n') { - let l = node._listeners || (node._listeners = {}); - name = toLowerCase(name.substring(2)); - // @TODO: this might be worth it later, un-breaks focus/blur bubbling in IE9: - // if (node.attachEvent) name = name=='focus'?'focusin':name=='blur'?'focusout':name; - if (value) { - if (!l[name]) node.addEventListener(name, eventProxy, !!NON_BUBBLING_EVENTS[name]); - } - else if (l[name]) { - node.removeEventListener(name, eventProxy, !!NON_BUBBLING_EVENTS[name]); - } - l[name] = value; - } - else if (name!=='list' && name!=='type' && !isSvg && name in node) { - setProperty(node, name, value==null ? '' : value); - if (value==null || value===false) node.removeAttribute(name); - } - else { - let ns = isSvg && name.match(/^xlink\:?(.+)/); - if (value==null || value===false) { - if (ns) node.removeAttributeNS('http://www.w3.org/1999/xlink', toLowerCase(ns[1])); - else node.removeAttribute(name); - } - else if (typeof value!=='object' && !isFunction(value)) { - if (ns) node.setAttributeNS('http://www.w3.org/1999/xlink', toLowerCase(ns[1]), value); - else node.setAttribute(name, value); - } - } -} - - -/** Attempt to set a DOM property to the given value. - * IE & FF throw for certain property-value combinations. - */ -function setProperty(node, name, value) { - try { - node[name] = value; - } catch (e) { } -} - - -/** Proxy an event to hooked event handlers - * @private - */ -function eventProxy(e) { - return this._listeners[e.type](options.event && options.event(e) || e); -} |