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 — :zap: faster element · nullstack/nullstack@8395790

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • shared
    • element.js
    • serializeParam.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎shared/element.js‎

Copy file name to clipboard
+11-13Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
import fragment from './fragment';
22

3-
function flattenChildren(children) {
4-
children = [].concat.apply([], children).map((child) => {
5-
if(child === null || child === undefined) return false;
6-
return child;
7-
});
8-
return [].concat.apply([], children);
3+
const seed = Object.freeze([])
4+
5+
function normalize(child) {
6+
return child ?? false
97
}
108

119
export default function element(type, props, ...children) {
12-
children = flattenChildren(children);
13-
if(type === 'textarea') {
10+
children = seed.concat(...children).map(normalize)
11+
if (type === 'textarea') {
1412
children = [children.join('')];
1513
}
16-
const attributes = {...props, children};
17-
if(type === 'element') {
14+
const attributes = { ...props, children };
15+
if (type === 'element') {
1816
type = attributes.tag || fragment;
1917
delete attributes.tag;
2018
}
21-
if(typeof(type) === 'function' && type.render !== undefined) {
22-
return {type, attributes, children: null}
19+
if (typeof type === 'function' && type.render !== undefined) {
20+
return { type, attributes, children: null }
2321
}
24-
return {type, attributes, children};
22+
return { type, attributes, children };
2523
}
Collapse file

‎shared/serializeParam.js‎

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default function serializeParam(value) {
2-
return value && value.toJSON !== undefined ? value.toJSON() : value;
2+
return value?.toJSON?.() ?? value;
33
}

0 commit comments

Comments
0 (0)
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.