mirror of
				https://github.com/jaandrle/deka-dom-el
				synced 2025-10-31 05:49:15 +01:00 
			
		
		
		
	🔤
This commit is contained in:
		| @@ -8,12 +8,12 @@ button.disabled = true; | |||||||
| const button2 = Object.assign( | const button2 = Object.assign( | ||||||
| 	document.createElement('button'), | 	document.createElement('button'), | ||||||
| 	{ | 	{ | ||||||
| 	textContent: "Click me", | 		textContent: "Click me", | ||||||
| 	className: "primary", | 		className: "primary", | ||||||
| 	disabled: true | 		disabled: true | ||||||
| 	} | 	} | ||||||
| ); | ); | ||||||
|  |  | ||||||
| // Add to DOM | // Add to DOM | ||||||
| document.body.appendChild(button); | document.body.append(button); | ||||||
| document.body.appendChild(button2); | document.body.append(button2); | ||||||
|   | |||||||
| @@ -2,14 +2,14 @@ | |||||||
| const div = document.createElement('div'); | const div = document.createElement('div'); | ||||||
| const h1 = document.createElement('h1'); | const h1 = document.createElement('h1'); | ||||||
| h1.textContent = 'Title'; | h1.textContent = 'Title'; | ||||||
| div.appendChild(h1); | div.append(h1); | ||||||
|  |  | ||||||
| const p = document.createElement('p'); | const p = document.createElement('p'); | ||||||
| p.textContent = 'Paragraph'; | p.textContent = 'Paragraph'; | ||||||
| div.appendChild(p); | div.append(p); | ||||||
|  |  | ||||||
| // appendChild doesn't return parent | // append doesn't return parent | ||||||
| // so chaining is not possible | // so chaining is not possible | ||||||
|  |  | ||||||
| // Add to DOM | // Add to DOM | ||||||
| document.body.appendChild(div); | document.body.append(div); | ||||||
|   | |||||||
| @@ -3,6 +3,7 @@ const paragraph= el("p", "See live-cycle events in console.", | |||||||
| 	el=> log({ type: "dde:created", detail: el }), | 	el=> log({ type: "dde:created", detail: el }), | ||||||
| 	on.connected(log), | 	on.connected(log), | ||||||
| 	on.disconnected(log), | 	on.disconnected(log), | ||||||
|  | ); | ||||||
|  |  | ||||||
| document.body.append( | document.body.append( | ||||||
| 	paragraph, | 	paragraph, | ||||||
|   | |||||||
| @@ -16,15 +16,16 @@ export function mnemonic(){ | |||||||
| 			el("code", "dispatchEvent(<event>[, <options>])(element)"), | 			el("code", "dispatchEvent(<event>[, <options>])(element)"), | ||||||
| 			" — just ", el("code", "<element>.dispatchEvent(new Event(<event>[, <options>]))") | 			" — just ", el("code", "<element>.dispatchEvent(new Event(<event>[, <options>]))") | ||||||
| 		), | 		), | ||||||
| 		el("li").append( |  | ||||||
| 			el("code", "dispatchEvent(<event>, <element>)([<detail>])"), |  | ||||||
| 			" — just ", el("code", "<element>.dispatchEvent(new Event(<event>))"), " or ", |  | ||||||
| 			el("code", "<element>.dispatchEvent(new CustomEvent(<event>, { detail: <detail> }))") |  | ||||||
| 		), |  | ||||||
| 		el("li").append( | 		el("li").append( | ||||||
| 			el("code", "dispatchEvent(<event>[, <options>])(<element>[, <detail>])"), | 			el("code", "dispatchEvent(<event>[, <options>])(<element>[, <detail>])"), | ||||||
| 			" — just ", el("code", "<element>.dispatchEvent(new Event(<event>[, <options>] ))"), " or ", | 			" — just ", el("code", "<element>.dispatchEvent(new Event(<event>[, <options>] ))"), " or ", | ||||||
| 			el("code", "<element>.dispatchEvent(new CustomEvent(<event>, { detail: <detail> }))") | 			el("code", "<element>.dispatchEvent(new CustomEvent(<event>, { detail: <detail> }))") | ||||||
| 		), | 		), | ||||||
|  | 		el("li").append( | ||||||
|  | 			el("code", "dispatchEvent(<event>[, <options>], <host>)([<detail>])"), | ||||||
|  | 			" — just ", el("code", "<host>().dispatchEvent(new Event(<event>[, <options>]))"), " or ", | ||||||
|  | 			el("code", "<host>().dispatchEvent(new CustomEvent(<event>, { detail: <detail> }[, <options>] ))"), | ||||||
|  | 			" (see scopes section of docs)" | ||||||
|  | 		), | ||||||
| 	); | 	); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -60,7 +60,7 @@ export function page({ pkg, info }){ | |||||||
| 				el("li", t`Declarative element creation with intuitive property assignment`), | 				el("li", t`Declarative element creation with intuitive property assignment`), | ||||||
| 				el("li", t`Chainable methods for natural DOM tree construction`), | 				el("li", t`Chainable methods for natural DOM tree construction`), | ||||||
| 				el("li", t`Simplified component patterns for code reuse`), | 				el("li", t`Simplified component patterns for code reuse`), | ||||||
| 				el("li", t`Normalized property/attribute handling across browsers`), | 				el("li", t`Normalized declarative property/attribute handling across browsers`), | ||||||
| 				el("li", t`Smart element return values for cleaner code flow`) | 				el("li", t`Smart element return values for cleaner code flow`) | ||||||
| 			) | 			) | ||||||
| 		), | 		), | ||||||
| @@ -95,7 +95,8 @@ export function page({ pkg, info }){ | |||||||
| 		el("p").append(...T` | 		el("p").append(...T` | ||||||
| 			The ${el("code", "assign")} function is the heart of dd<el>'s element property handling. It is internally | 			The ${el("code", "assign")} function is the heart of dd<el>'s element property handling. It is internally | ||||||
| 			used to assign properties using the ${el("code", "el")} function. ${el("code", "assign")} provides | 			used to assign properties using the ${el("code", "el")} function. ${el("code", "assign")} provides | ||||||
| 			intelligent assignment of both properties (IDL) and attributes: | 			intelligent assignment of both ${el("a", { textContent: "properties (IDL)", ...references.mdn_idl })} | ||||||
|  | 			and attributes: | ||||||
| 		`), | 		`), | ||||||
| 		el("div", { class: "function-table" }).append( | 		el("div", { class: "function-table" }).append( | ||||||
| 			el("dl").append( | 			el("dl").append( | ||||||
| @@ -131,7 +132,7 @@ export function page({ pkg, info }){ | |||||||
| 		el(h3, t`Building DOM Trees with Chainable Methods`), | 		el(h3, t`Building DOM Trees with Chainable Methods`), | ||||||
| 		el("p").append(...T` | 		el("p").append(...T` | ||||||
| 			One of the most powerful features of dd<el> is its approach to building element trees. | 			One of the most powerful features of dd<el> is its approach to building element trees. | ||||||
| 			Unlike the native DOM API which doesn't return the parent after appendChild(), dd<el>'s | 			Unlike the native DOM API which doesn't return the parent after append(), dd<el>'s | ||||||
| 			append() always returns the parent element: | 			append() always returns the parent element: | ||||||
| 		`), | 		`), | ||||||
| 		el("div", { class: "illustration" }).append( | 		el("div", { class: "illustration" }).append( | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ const references= { | |||||||
| 	mdn_mutation: { | 	mdn_mutation: { | ||||||
| 		href: "https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver", | 		href: "https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver", | ||||||
| 	}, | 	}, | ||||||
| 	/** Readding the element to the DOM fix by Vue */ | 	/** TODO Readding the element to the DOM fix by Vue */ | ||||||
| 	vue_fix: { | 	vue_fix: { | ||||||
| 		title: t`Vue and Web Components, lifecycle implementation readding the element to the DOM`, | 		title: t`Vue and Web Components, lifecycle implementation readding the element to the DOM`, | ||||||
| 		href: "https://vuejs.org/guide/extras/web-components.html#lifecycle", | 		href: "https://vuejs.org/guide/extras/web-components.html#lifecycle", | ||||||
| @@ -117,7 +117,7 @@ export function page({ pkg, info }){ | |||||||
| 			el("div", { className: "tab", "data-tab": "addon" }).append( | 			el("div", { className: "tab", "data-tab": "addon" }).append( | ||||||
| 				el("h4", t`Addon Approach`), | 				el("h4", t`Addon Approach`), | ||||||
| 				el(code, { src: fileURL("./components/examples/events/chain-event.js"), page_id }), | 				el(code, { src: fileURL("./components/examples/events/chain-event.js"), page_id }), | ||||||
| 				el("p", t`Uses the addon pattern, see above.`) | 				el("p", t`Uses the addon pattern (so adds the event listener to the element), see above.`) | ||||||
| 			) | 			) | ||||||
| 		), | 		), | ||||||
| 		el("p").append(...T` | 		el("p").append(...T` | ||||||
| @@ -156,7 +156,8 @@ export function page({ pkg, info }){ | |||||||
| 			You can think of an Addon as an "oncreate" event handler. | 			You can think of an Addon as an "oncreate" event handler. | ||||||
| 		`), | 		`), | ||||||
| 		el("p").append(...T` | 		el("p").append(...T` | ||||||
| 			dd<el> provides three additional lifecycle events that correspond to custom element lifecycle callbacks: | 			dd<el> provides two additional lifecycle events that correspond to ${el("a", { textContent: | ||||||
|  | 				"custom element", ...references.mdn_customElements })} lifecycle callbacks: | ||||||
| 		`), | 		`), | ||||||
| 		el("div", { className: "function-table" }).append( | 		el("div", { className: "function-table" }).append( | ||||||
| 			el("dl").append( | 			el("dl").append( | ||||||
| @@ -180,7 +181,9 @@ export function page({ pkg, info }){ | |||||||
| 		el("div", { className: "warning" }).append( | 		el("div", { className: "warning" }).append( | ||||||
| 			el("ul").append( | 			el("ul").append( | ||||||
| 				el("li").append(...T` | 				el("li").append(...T` | ||||||
| 					Always use ${el("code", "on.*")} functions, not ${el("code", "on('dde:*', ...)")}, for proper registration | 					Always use ${el("code", "on.*")} functions as library must ensure proper (MutationObserver) | ||||||
|  | 					registration, not ${el("code", "on('dde:*', ...)")}, even the native event system is used with event | ||||||
|  | 					names prefixed with ${el("code", "dde:")}. | ||||||
| 				`), | 				`), | ||||||
| 				el("li").append(...T` | 				el("li").append(...T` | ||||||
| 					Use lifecycle events sparingly, as they require internal tracking | 					Use lifecycle events sparingly, as they require internal tracking | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user