UNPKG

@haxtheweb/haxcms-nodejs

Version:

HAXcms single and multisite nodejs server, api, and administration

10 lines 5 kB
/** @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ import"../utils/boot.js";import{wrap as e}from"../utils/wrap.js";import"../utils/settings.js";import{FlattenedNodesObserver as t}from"../utils/flattened-nodes-observer.js";export{flush,enqueueDebouncer as addDebouncer}from"../utils/flush.js";import{Debouncer as o}from"../utils/debounce.js";const i=Element.prototype,r=i.matches||i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector;export const matchesSelector=function(e,t){return r.call(e,t)};class DomApiNative{constructor(e){window.ShadyDOM&&window.ShadyDOM.inUse&&window.ShadyDOM.patch(e),this.node=e}observeNodes(e){return new t(this.node,e)}unobserveNodes(e){e.disconnect()}notifyObserver(){}deepContains(t){if(e(this.node).contains(t))return!0;let o=t,i=t.ownerDocument;for(;o&&o!==i&&o!==this.node;)o=e(o).parentNode||e(o).host;return o===this.node}getOwnerRoot(){return e(this.node).getRootNode()}getDistributedNodes(){return"slot"===this.node.localName?e(this.node).assignedNodes({flatten:!0}):[]}getDestinationInsertionPoints(){let t=[],o=e(this.node).assignedSlot;for(;o;)t.push(o),o=e(o).assignedSlot;return t}importNode(t,o){let i=this.node instanceof Document?this.node:this.node.ownerDocument;return e(i).importNode(t,o)}getEffectiveChildNodes(){return t.getFlattenedNodes(this.node)}queryDistributedElements(e){let t=this.getEffectiveChildNodes(),o=[];for(let i,r=0,n=t.length;r<n&&(i=t[r]);r++)i.nodeType===Node.ELEMENT_NODE&&matchesSelector(i,e)&&o.push(i);return o}get activeElement(){let e=this.node;return void 0!==e._activeElement?e._activeElement:e.activeElement}}function forwardReadOnlyProperties(e,t){for(let o=0;o<t.length;o++){let i=t[o];Object.defineProperty(e,i,{get:function(){return this.node[i]},configurable:!0})}}export class EventApi{constructor(e){this.event=e}get rootTarget(){return this.path[0]}get localTarget(){return this.event.target}get path(){return this.event.composedPath()}}DomApiNative.prototype.cloneNode,DomApiNative.prototype.appendChild,DomApiNative.prototype.insertBefore,DomApiNative.prototype.removeChild,DomApiNative.prototype.replaceChild,DomApiNative.prototype.setAttribute,DomApiNative.prototype.removeAttribute,DomApiNative.prototype.querySelector,DomApiNative.prototype.querySelectorAll,DomApiNative.prototype.parentNode,DomApiNative.prototype.firstChild,DomApiNative.prototype.lastChild,DomApiNative.prototype.nextSibling,DomApiNative.prototype.previousSibling,DomApiNative.prototype.firstElementChild,DomApiNative.prototype.lastElementChild,DomApiNative.prototype.nextElementSibling,DomApiNative.prototype.previousElementSibling,DomApiNative.prototype.childNodes,DomApiNative.prototype.children,DomApiNative.prototype.classList,DomApiNative.prototype.textContent,DomApiNative.prototype.innerHTML;let n=DomApiNative;if(window.ShadyDOM&&window.ShadyDOM.inUse&&window.ShadyDOM.noPatch&&window.ShadyDOM.Wrapper){class Wrapper extends window.ShadyDOM.Wrapper{}Object.getOwnPropertyNames(DomApiNative.prototype).forEach((e=>{"activeElement"!=e&&(Wrapper.prototype[e]=DomApiNative.prototype[e])})),forwardReadOnlyProperties(Wrapper.prototype,["classList"]),n=Wrapper,Object.defineProperties(EventApi.prototype,{localTarget:{get(){const e=this.event.currentTarget,t=e&&dom(e).getOwnerRoot(),o=this.path;for(let e=0;e<o.length;e++){const i=o[e];if(dom(i).getOwnerRoot()===t)return i}},configurable:!0},path:{get(){return window.ShadyDOM.composedPath(this.event)},configurable:!0}})}else!function forwardMethods(e,t){for(let o=0;o<t.length;o++){let i=t[o];e[i]=function(){return this.node[i].apply(this.node,arguments)}}}(DomApiNative.prototype,["cloneNode","appendChild","insertBefore","removeChild","replaceChild","setAttribute","removeAttribute","querySelector","querySelectorAll","attachShadow"]),forwardReadOnlyProperties(DomApiNative.prototype,["parentNode","firstChild","lastChild","nextSibling","previousSibling","firstElementChild","lastElementChild","nextElementSibling","previousElementSibling","childNodes","children","classList","shadowRoot"]),function forwardProperties(e,t){for(let o=0;o<t.length;o++){let i=t[o];Object.defineProperty(e,i,{get:function(){return this.node[i]},set:function(e){this.node[i]=e},configurable:!0})}}(DomApiNative.prototype,["textContent","innerHTML","className"]);export const DomApi=n;export const dom=function(e){if((e=e||document)instanceof n)return e;if(e instanceof EventApi)return e;let t=e.__domApi;return t||(t=e instanceof Event?new EventApi(e):new n(e),e.__domApi=t),t};