UNPKG

smartdown

Version:

A library for translating, rendering and interacting with Smartdown documents. Smartdown is an extension of Markdown that provides richer media support and reactive programming capability.

2 lines 8.4 kB
/*! For license information please see webcomponents-pf_dom.js.LICENSE.txt */ (function(){"use strict";function e(e){var t=0;return function(){return t<e.length?{done:!1,value:e[t++]}:{done:!0}}}function t(t){var n="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return n?n.call(t):{next:e(t)}}var n=document.createEvent("Event");if(n.initEvent("foo",!0,!0),n.preventDefault(),!n.defaultPrevented){var o=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){this.cancelable&&(o.call(this),Object.defineProperty(this,"defaultPrevented",{get:function(){return!0},configurable:!0}))}}var r=/Trident/.test(navigator.userAgent);if(!window.Event||r&&"function"!=typeof window.Event){var i=window.Event;if(window.Event=function(e,t){t=t||{};var n=document.createEvent("Event");return n.initEvent(e,!!t.bubbles,!!t.cancelable),n},i){for(var l in i)window.Event[l]=i[l];window.Event.prototype=i.prototype}}if((!window.CustomEvent||r&&"function"!=typeof window.CustomEvent)&&(window.CustomEvent=function(e,t){t=t||{};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,!!t.bubbles,!!t.cancelable,t.detail),n},window.CustomEvent.prototype=window.Event.prototype),!window.MouseEvent||r&&"function"!=typeof window.MouseEvent){var a=window.MouseEvent;if(window.MouseEvent=function(e,t){t=t||{};var n=document.createEvent("MouseEvent");return n.initMouseEvent(e,!!t.bubbles,!!t.cancelable,t.view||window,t.detail,t.screenX,t.screenY,t.clientX,t.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,t.button,t.relatedTarget),n},a)for(var c in a)window.MouseEvent[c]=a[c];window.MouseEvent.prototype=a.prototype}var p,u=function(){function e(){r++}var t=!1,n=!1,o={get capture(){return t=!0},get once(){return n=!0}},r=0,i=document.createElement("div");i.addEventListener("click",e,o);var l=t&&n;return l&&(i.dispatchEvent(new Event("click")),i.dispatchEvent(new Event("click")),l=1==r),i.removeEventListener("click",e,o),l}(),d=null!==(p=window.EventTarget)&&void 0!==p?p:window.Node;if(!u&&"addEventListener"in d.prototype){var v=function(e){if(!e||"object"!=typeof e&&"function"!=typeof e){var t=!!e;e=!1}else t=!!e.capture,e=!!e.once;return{capture:t,once:e}},s=d.prototype.addEventListener,f=d.prototype.removeEventListener,y=new WeakMap,h=new WeakMap,w=function(e,t,n){var o=n?y:h;return void 0===(n=o.get(e))&&o.set(e,n=new Map),void 0===(e=n.get(t))&&n.set(t,e=new WeakMap),e};d.prototype.addEventListener=function(e,t,n){var o=this;if(null!=t){var r=(n=v(n)).capture;n=n.once;var i=w(this,e,r);if(!i.has(t)){var l=n?function(n){return i.delete(t),f.call(o,e,l,r),"function"==typeof t?t.call(o,n):"function"==typeof(null==t?void 0:t.handleEvent)?t.handleEvent(n):void 0}:null;i.set(t,l),s.call(this,e,null!=l?l:t,r)}}},d.prototype.removeEventListener=function(e,t,n){if(null!=t){n=v(n).capture;var o=w(this,e,n),r=o.get(t);void 0!==r&&(o.delete(t),f.call(this,e,null!=r?r:t,n))}}}Object.getOwnPropertyDescriptor(Node.prototype,"baseURI")||Object.defineProperty(Node.prototype,"baseURI",{get:function(){var e=(this.ownerDocument||this).querySelector("base[href]");return e&&e.href||window.location.href},configurable:!0,enumerable:!0});var b,m,g=Element.prototype,E=null!==(b=Object.getOwnPropertyDescriptor(g,"attributes"))&&void 0!==b?b:Object.getOwnPropertyDescriptor(Node.prototype,"attributes"),O=null!==(m=null==E?void 0:E.get)&&void 0!==m?m:function(){return this.attributes},N=Array.prototype.map;g.hasOwnProperty("getAttributeNames")||(g.getAttributeNames=function(){return N.call(O.call(this),(function(e){return e.name}))});var P,D=Element.prototype;D.hasOwnProperty("matches")||(D.matches=null!==(P=D.webkitMatchesSelector)&&void 0!==P?P:D.msMatchesSelector);var j=Node.prototype.appendChild;function x(e){(e=e.prototype).hasOwnProperty("append")||Object.defineProperty(e,"append",{configurable:!0,enumerable:!0,writable:!0,value:function(e){for(var n=[],o=0;o<arguments.length;++o)n[o]=arguments[o];for(o=(n=t(n)).next();!o.done;o=n.next())o=o.value,j.call(this,"string"==typeof o?document.createTextNode(o):o)}})}x(Document),x(DocumentFragment),x(Element);var C,M,L=Node.prototype.insertBefore,T=null!==(M=null===(C=Object.getOwnPropertyDescriptor(Node.prototype,"firstChild"))||void 0===C?void 0:C.get)&&void 0!==M?M:function(){return this.firstChild};function A(e){(e=e.prototype).hasOwnProperty("prepend")||Object.defineProperty(e,"prepend",{configurable:!0,enumerable:!0,writable:!0,value:function(e){for(var n=[],o=0;o<arguments.length;++o)n[o]=arguments[o];o=T.call(this);for(var r=(n=t(n)).next();!r.done;r=n.next())r=r.value,L.call(this,"string"==typeof r?document.createTextNode(r):r,o)}})}A(Document),A(DocumentFragment),A(Element);var S,k,W=Node.prototype.appendChild,B=Node.prototype.removeChild,K=null!==(k=null===(S=Object.getOwnPropertyDescriptor(Node.prototype,"firstChild"))||void 0===S?void 0:S.get)&&void 0!==k?k:function(){return this.firstChild};function F(e){(e=e.prototype).hasOwnProperty("replaceChildren")||Object.defineProperty(e,"replaceChildren",{configurable:!0,enumerable:!0,writable:!0,value:function(e){for(var n=[],o=0;o<arguments.length;++o)n[o]=arguments[o];for(;null!==(o=K.call(this));)B.call(this,o);for(o=(n=t(n)).next();!o.done;o=n.next())o=o.value,W.call(this,"string"==typeof o?document.createTextNode(o):o)}})}F(Document),F(DocumentFragment),F(Element);var I,R,U,X,Y=Node.prototype.insertBefore,q=null!==(R=null===(I=Object.getOwnPropertyDescriptor(Node.prototype,"parentNode"))||void 0===I?void 0:I.get)&&void 0!==R?R:function(){return this.parentNode},G=null!==(X=null===(U=Object.getOwnPropertyDescriptor(Node.prototype,"nextSibling"))||void 0===U?void 0:U.get)&&void 0!==X?X:function(){return this.nextSibling};function H(e){(e=e.prototype).hasOwnProperty("after")||Object.defineProperty(e,"after",{configurable:!0,enumerable:!0,writable:!0,value:function(e){for(var n=[],o=0;o<arguments.length;++o)n[o]=arguments[o];if(null!==(o=q.call(this)))for(var r=G.call(this),i=(n=t(n)).next();!i.done;i=n.next())i=i.value,Y.call(o,"string"==typeof i?document.createTextNode(i):i,r)}})}H(CharacterData),H(Element);var V,z,J=Node.prototype.insertBefore,Q=null!==(z=null===(V=Object.getOwnPropertyDescriptor(Node.prototype,"parentNode"))||void 0===V?void 0:V.get)&&void 0!==z?z:function(){return this.parentNode};function Z(e){(e=e.prototype).hasOwnProperty("before")||Object.defineProperty(e,"before",{configurable:!0,enumerable:!0,writable:!0,value:function(e){for(var n=[],o=0;o<arguments.length;++o)n[o]=arguments[o];if(null!==(o=Q.call(this)))for(var r=(n=t(n)).next();!r.done;r=n.next())r=r.value,J.call(o,"string"==typeof r?document.createTextNode(r):r,this)}})}Z(CharacterData),Z(Element);var $,_,ee=Node.prototype.removeChild,te=null!==(_=null===($=Object.getOwnPropertyDescriptor(Node.prototype,"parentNode"))||void 0===$?void 0:$.get)&&void 0!==_?_:function(){return this.parentNode};function ne(e){(e=e.prototype).hasOwnProperty("remove")||Object.defineProperty(e,"remove",{configurable:!0,enumerable:!0,writable:!0,value:function(){var e=te.call(this);e&&ee.call(e,this)}})}ne(CharacterData),ne(Element);var oe,re,ie=Node.prototype.insertBefore,le=Node.prototype.removeChild,ae=null!==(re=null===(oe=Object.getOwnPropertyDescriptor(Node.prototype,"parentNode"))||void 0===oe?void 0:oe.get)&&void 0!==re?re:function(){return this.parentNode};function ce(e){(e=e.prototype).hasOwnProperty("replaceWith")||Object.defineProperty(e,"replaceWith",{configurable:!0,enumerable:!0,writable:!0,value:function(e){for(var n=[],o=0;o<arguments.length;++o)n[o]=arguments[o];if(null!==(o=ae.call(this))){for(var r=(n=t(n)).next();!r.done;r=n.next())r=r.value,ie.call(o,"string"==typeof r?document.createTextNode(r):r,this);le.call(o,this)}}})}ce(CharacterData),ce(Element);var pe=window.Element.prototype,ue=window.HTMLElement.prototype,de=window.SVGElement.prototype;!ue.hasOwnProperty("classList")||pe.hasOwnProperty("classList")||de.hasOwnProperty("classList")||Object.defineProperty(pe,"classList",Object.getOwnPropertyDescriptor(ue,"classList"));var ve=Element.prototype,se=Element.prototype.hasAttribute,fe=Element.prototype.setAttribute,ye=Element.prototype.removeAttribute;ve.hasOwnProperty("toggleAttribute")||(ve.toggleAttribute=function(e,t){return void 0===t?se.call(this,e)?(ye.call(this,e),!1):(fe.call(this,e,""),!0):t?(se.call(this,e)||fe.call(this,e,""),!0):(ye.call(this,e),!1)})}).call(this);