UNPKG

@haxtheweb/haxcms-nodejs

Version:

HAXcms single and multisite nodejs server, api, and administration

12 lines 2.11 kB
/** * @fileoverview * @suppress {checkPrototypalTypes} * @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{PropertyAccessors as t}from"./property-accessors.js";import{dedupingMixin as e}from"../utils/mixin.js";const r=/:host\(:dir\((ltr|rtl)\)\)/g,i=/([\s\w-#\.\[\]\*]*):dir\((ltr|rtl)\)/g,s=/:dir\((?:ltr|rtl)\)/,c=Boolean(window.ShadyDOM&&window.ShadyDOM.inUse),n=[];let o=null,a="";function getRTL(){a=document.documentElement.getAttribute("dir")}function setRTL(t){if(!t.__autoDirOptOut){t.setAttribute("dir",a)}}function updateDirection(){getRTL(),a=document.documentElement.getAttribute("dir");for(let t=0;t<n.length;t++)setRTL(n[t])}export const DirMixin=e((e=>{c||o||(getRTL(),o=new MutationObserver(updateDirection),o.observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]}));const a=t(e);class Dir extends a{static _processStyleText(t,e){return t=a._processStyleText.call(this,t,e),!c&&s.test(t)&&(t=this._replaceDirInCssText(t),this.__activateDir=!0),t}static _replaceDirInCssText(t){let e=t;return e=e.replace(r,':host([dir="$1"])'),e=e.replace(i,':host([dir="$2"]) $1'),e}constructor(){super(),this.__autoDirOptOut=!1}ready(){super.ready(),this.__autoDirOptOut=this.hasAttribute("dir")}connectedCallback(){a.prototype.connectedCallback&&super.connectedCallback(),this.constructor.__activateDir&&(!function takeRecords(){o&&o.takeRecords().length&&updateDirection()}(),n.push(this),setRTL(this))}disconnectedCallback(){if(a.prototype.disconnectedCallback&&super.disconnectedCallback(),this.constructor.__activateDir){const t=n.indexOf(this);t>-1&&n.splice(t,1)}}}return Dir.__activateDir=!1,Dir}));