Skip to content

Commit 6e2a9e4

Browse files
committed
remove commented out code
1 parent d2b784b commit 6e2a9e4

File tree

2 files changed

+15
-35
lines changed

2 files changed

+15
-35
lines changed

src/index.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// import { toChildArray } from 'preact';
2-
import { encodeEntities, indent, isLargeString, styleObjToCss, assign, getChildren /*, getNodeProps*/ } from './util';
1+
import { encodeEntities, indent, isLargeString, styleObjToCss, assign, getChildren } from './util';
32
import { ENABLE_PRETTY } from '../env';
43

54
const SHALLOW = { shallow: true };
@@ -40,7 +39,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
4039
}
4140

4241
let nodeName = vnode.type,
43-
attributes = vnode.props,
42+
props = vnode.props,
4443
isComponent = false;
4544
context = context || {};
4645
opts = opts || {};
@@ -60,8 +59,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
6059
nodeName = getComponentName(nodeName);
6160
}
6261
else {
63-
let props = vnode.props, //props = getNodeProps(vnode),
64-
rendered;
62+
let rendered;
6563

6664
if (!nodeName.prototype || typeof nodeName.prototype.render!=='function') {
6765
// stateless functional components
@@ -90,23 +88,23 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
9088
// render JSX to HTML
9189
let s = '', html;
9290

93-
if (attributes) {
94-
let attrs = Object.keys(attributes);
91+
if (props) {
92+
let attrs = Object.keys(props);
9593

9694
// allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)
9795
if (opts && opts.sortAttributes===true) attrs.sort();
9896

9997
for (let i=0; i<attrs.length; i++) {
10098
let name = attrs[i],
101-
v = attributes[name];
99+
v = props[name];
102100
if (name==='children') continue;
103101

104102
if (name.match(/[\s\n\\/='"\0<>]/)) continue;
105103

106104
if (!(opts && opts.allAttributes) && (name==='key' || name==='ref')) continue;
107105

108106
if (name==='className') {
109-
if (attributes.class) continue;
107+
if (props.class) continue;
110108
name = 'class';
111109
}
112110
else if (isSvgMode && name.match(/^xlink:?./)) {
@@ -163,7 +161,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
163161
}
164162
s += html;
165163
}
166-
else if (vnode.props && getChildren(children = [], vnode.props.children).length) {
164+
else if (props && getChildren(children = [], props.children).length) {
167165
let hasLarge = pretty && ~s.indexOf('\n');
168166
for (let i=0; i<children.length; i++) {
169167
let child = children[i];

src/util.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// import { toChildArray } from 'preact';
2-
31
// DOM properties that should NOT have "px" added when numeric
42
export const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
53

@@ -47,6 +45,13 @@ export function assign(obj, props) {
4745
return obj;
4846
}
4947

48+
/**
49+
* Get flattened children from the children prop
50+
* @param {Array} accumulator
51+
* @param {any} children A `props.children` opaque object.
52+
* @returns {Array} accumulator
53+
* @private
54+
*/
5055
export function getChildren(accumulator, children) {
5156
if (Array.isArray(children)) {
5257
children.reduce(getChildren, accumulator);
@@ -56,26 +61,3 @@ export function getChildren(accumulator, children) {
5661
}
5762
return accumulator;
5863
}
59-
60-
/**
61-
* Reconstruct Component-style `props` from a VNode.
62-
* Ensures default/fallback values from `defaultProps`:
63-
* Own-properties of `defaultProps` not present in `vnode.props` are added.
64-
* @param {import('preact').VNode} vnode The VNode to get props for
65-
* @returns {object} The props to use for this VNode
66-
*/
67-
// export function getNodeProps(vnode) {
68-
// let props = assign({}, vnode.props);
69-
// props.children = toChildArray(vnode);
70-
71-
// let defaultProps = vnode.type.defaultProps;
72-
// if (defaultProps!==undefined) {
73-
// for (let i in defaultProps) {
74-
// if (props[i]===undefined) {
75-
// props[i] = defaultProps[i];
76-
// }
77-
// }
78-
// }
79-
80-
// return props;
81-
// }

0 commit comments

Comments
 (0)