preact-custom-element@4.2.1
変更点
importを書き換えた
はShadow DOMに対応していないので使わない code:script.js
import{h as t,hydrate as e,render as n,cloneElement as o}from"../htm@3.0.4%2Fpreact/script.js";function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=argumentse;for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(to=no)}return t}).apply(this,arguments)}function i(t){this.getChildContext=function(){return t.context};var e=t.children,n=function(t,e){if(null==t)return{};var n,o,r={},i=Object.keys(t);for(o=0;o<i.length;o++)e.indexOf(n=io)>=0||(rn=tn);return r}(t,"context","children");return o(e,n)}function a(){var o=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(o),this._vdom=t(i,r({},this._props,{context:o.detail.context}),function e(n,o){if(3===n.nodeType)return n.data;if(1!==n.nodeType)return null;var r=[],i={},a=0,c=n.attributes,l=n.childNodes;for(a=c.length;a--;)"slot"!==ca.name&&(i[ca.name]=ca.value,i[s(ca.name)]=ca.value);for(a=l.length;a--;){var p=e(la,null),d=la.slot;d?id=t(u,{name:d},p):ra=p}var h=o?t(u,null,r):r;return t(o||n.nodeName.toLowerCase(),i,h)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?e:n)(this._vdom,this._root)}function s(t){return t.replace(/-(\w)/g,function(t,e){return e?e.toUpperCase():""})}function c(t,e,r){if(this._vdom){var i={};it=r=null==r?void 0:r,is(t)=r,this._vdom=o(this._vdom,i),n(this._vdom,this._root)}}function l(){n(this._vdom=null,this._root)}function u(e,n){var o=this;return t("slot",r({},e,{ref:function(t){t?(o.ref=t,o._listener||(o._listener=function(t){t.stopPropagation(),t.detail.context=n},t.addEventListener("_preact",o._listener))):o.ref.removeEventListener("_preact",o._listener)}}))}export default function(t,e,n,o){function r(){var e=Reflect.construct(HTMLElement,[],r);return e._vdomComponent=t,e._root=o&&o.shadow?e.attachShadow({mode:"open"}):e,e}return(r.prototype=Object.create(HTMLElement.prototype)).constructor=r,r.prototype.connectedCallback=a,r.prototype.attributeChangedCallback=c,r.prototype.disconnectedCallback=l,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),r.observedAttributes=n,n.forEach(function(t){Object.defineProperty(r.prototype,t,{get:function(){return this._vdom.propst},set:function(e){this._vdom?this.attributeChangedCallback(t,null,e):(this._props||(this._props={}),this._propst=e,this.connectedCallback());var n=typeof e;null!=e&&"string"!==n&&"boolean"!==n&&"number"!==n||this.setAttribute(t,e)}})}),customElements.define(e||t.tagName||t.displayName||t.name,r)}