GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — nullstack/client/render.js at master · GuiDevloper/nullstack

Expand file tree

/

render.js

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
70 lines (62 loc) · 2.28 KB
/

render.js

Copy path

File metadata and controls

70 lines (62 loc) · 2.28 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { sanitizeInnerHtml } from '../shared/sanitizeString'
import generateTruthyString from '../shared/generateTruthyString'
import { isFalse, isText } from '../shared/nodes'
import { anchorableElement } from './anchorableNode'
import { generateCallback, generateSubject } from './events'
import { ref } from './ref'
export default function render(node, isSvg = false) {
if (isFalse(node) || node.type === 'head') {
node.element = document.createComment('')
return node.element
}
if (isText(node)) {
node.element = document.createTextNode(node.text)
return node.element
}
isSvg = isSvg || node.type === 'svg'
if (isSvg) {
node.element = document.createElementNS('http://www.w3.org/2000/svg', node.type)
} else {
node.element = document.createElement(node.type)
}
ref(node.attributes, node.element)
for (const name in node.attributes) {
if (name === 'debounce') continue
if (name === 'html') {
node.element.innerHTML = sanitizeInnerHtml(node.attributes[name])
node.head || anchorableElement(node.element)
} else if (name.startsWith('on')) {
if (node.attributes[name] !== undefined) {
const eventName = name.substring(2)
const callback = generateCallback(node.element, name)
node.element.addEventListener(eventName, callback)
generateSubject(node.element, node.attributes, name)
}
} else {
let nodeValue
if ((name === 'class' || name === 'style') && Array.isArray(node.attributes[name])) {
nodeValue = generateTruthyString(node.attributes[name])
} else {
nodeValue = node.attributes[name]
}
const type = typeof nodeValue
if (type !== 'object' && type !== 'function') {
if (name !== 'value' && nodeValue === true) {
node.element.setAttribute(name, '')
} else if (name === 'value' || (nodeValue !== false && nodeValue !== null && nodeValue !== undefined)) {
node.element.setAttribute(name, nodeValue)
}
}
}
}
if (!node.attributes.html) {
for (let i = 0; i < node.children.length; i++) {
const child = render(node.children[i], isSvg)
node.element.appendChild(child)
}
if (node.type === 'select') {
node.element.value = node.attributes.value
}
}
return node.element
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.