import { forwardRef } from 'preact-forwardref';
const Foo = forwardRef((props, ref) => {
return <div ref={ref} />
});
render( console.log(div)} />, document.body);
/** | |
* Chunkify | |
* Google Chrome Speech Synthesis Chunking Pattern | |
* Fixes inconsistencies with speaking long texts in speechUtterance objects | |
* Licensed under the MIT License | |
* | |
* Peter Woolley and Brett Zamir | |
*/ | |
var speechUtteranceChunker = function (utt, settings, callback) { |
; (function (global, define) { define('module-name', function (require, exports, module) { | |
// CommonJS style code here | |
/*! | |
* UMD/AMD/Global context Module Loader wrapper | |
* based off https://gist.github.com/tejacques/202a8f2d198ddd54a409 | |
* | |
* This wrapper will try to use a module loader with the | |
* following priority: | |
* |
import regexparam from 'https://unpkg.com/regexparam@1/dist/regexparam.mjs'; | |
/** | |
* <url-route href="/profile/:user"> | |
* <div>some content here</div> | |
* </url-route> | |
*/ | |
customElements.define('url-route', class UrlRoute extends HTMLElement { | |
connectedCallback() { | |
this.route = regexparam(this.getAttribute('href')); |
import { h, hydrate, Component } from 'preact'; | |
function interopDefault(mod) { | |
return mod && mod.default || mod; | |
} | |
export function ServerHydrator({ load, ...props }) { | |
const Child = interopDefault(load()); | |
return ( | |
<section> |
🔍 see jay, yes! 🎉 / 👨🏻💻 see, JS! 👾 / ⚓️ sea JS ⛴
If you're publishing ES Modules, you need to also publish CommonJS versions of those modules.
This isn't to support old browsers or Node versions: even in Node 14, using require()
to load a module won't work if it's only available as ESM.
cjyes
is the bare minimum fix for this problem. You write ES Modules and fill out a valid package.json
, and it'll generate the corresponding CommonJS files pretty much instantly. cjyes
takes up 500kb of disk space including its two dependencies.
This is a 1.1kb polyfill for Module Workers.
It adds support for new Worker('..',{type:'module'})
to all modern browsers (those that support fetch).
Copy module-workers-polyfill.js
to your web directory, then load it using an import or a script tag.
It just needs to be loaded before instantiating your Worker.
Experimental hooks-based bindings for Unistore. Available on npm:
npm i unistore-hooks
Note: this should also work with React, just alias
"preact"
and"preact/hooks"
to"react"
in your bundler.
import { options } from 'preact'; | |
// Fix Preact rendering when Google Translate breaks the DOM | |
const FONT_AS_TEXT = { | |
localName: { | |
value: null | |
}, | |
nodeType: { | |
value: 3 | |
}, |
It's possible to render HTML in Preact using the dangerouslySetInnerHTML
prop,
however doing so bypasses the Virtual DOM entirely. This may be reasonable for
static HTML, but interactivity can be a little painful to graft on without VDOM.
There is another technique available that melds HTML to Virtual DOM without such limitations.