Skip to content

Instantly share code, notes, and snippets.

@matthewp
matthewp / example-minified.html
Last active January 16, 2020 18:00
SSR web components
<!doctype html>
<html lang="en">
<title>Web component SSR</title>
<script>
customElements.define("shadow-root",class extends HTMLElement{connectedCallback(){let a=this.parentNode,b=a.firstElementChild;this.remove(),a.attachShadow({mode:"open"}).append(b.content.cloneNode(!0))}});
</script>
<a-component>
<template>
<header>
@matthewp
matthewp / example.html
Created June 12, 2019 12:01
Observed attributes dynamic
<!doctype html>
<html lang="en">
<title>Some title</title>
<my-element id="myel"><my-element>
<script type="module">
class MyElement extends HTMLElement {
static get observedAttributes() {
let defines = this.define;
@matthewp
matthewp / .gitignore
Created May 8, 2019 17:56
xml2js in steal
node_modules/
@matthewp
matthewp / explainer.md
Last active May 1, 2019 12:11
Client/server abstractions

One of the most difficult problems in web development today is the need to use the same views to render HTML on a web server and to update DOM nodes to reflect changes that occur on the client.

This desire comes down the need to server render for SEO, performance, and fallback reasons, while additionally needing complex, interactive applications.

Most frameworks today have consolidated on the idea of Isomorphic JavaScript, sometimes also called Universal JavaScript, as a solution to this problem.

Problem

I find isomorphism to be an inadequate solution to the use-case stated above. Isomorphism has the following problems:

@matthewp
matthewp / .gitignore
Created February 28, 2019 14:41
Preact in Deno
node_modules/
out.js
@matthewp
matthewp / explainer.md
Last active February 28, 2019 13:27
Bitovi Finite State Machines

Finite State Machines in CanJS

Finite State Machines (FSM) provide a mechanism for transitioning between states in a program. By declaratively listing all possible states up front, and how to transition between them, the state machine can ensure that no invalid state is ever reached.

This proposal lays out a plan for us to adopt FSMs into the CanJS (and greater Bitovi) ecosystem especially surrounding our CRUD initiatives.

This drawing shows how state transitions occur within a client project we are working on.

Terminology

@matthewp
matthewp / decorate-element.js
Last active April 23, 2020 07:57
decorate-element
function decorate(tag, template) {
customElements.define(tag, class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
let root = this.shadowRoot;
if(!root.firstChild) {
@matthewp
matthewp / sorting.txt
Created October 31, 2018 15:21
Sorting problem
<div>
<main id="main1"></main> 0
</div>
div.appendChild(main2);
div.removeChild(main1);
<div>
<main id="main2"></main> 0
</div>
@matthewp
matthewp / scripts.js
Created October 29, 2018 14:53
Debugging incremental rendering instruction mismatch
function printDocument(node, startIndex = 0) {
let skip, tmp;
let depth = 0;
let index = startIndex;
let items = [];
function add(node) {
@matthewp
matthewp / debug.js
Created October 26, 2018 12:55
Print the document, for debugging
function printDocument(node, startIndex = 0) {
let skip, tmp;
let depth = 0;
let index = startIndex;
let items = [];
function add(node) {