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' ;
3
2
import { ENABLE_PRETTY } from '../env' ;
4
3
5
4
const SHALLOW = { shallow : true } ;
@@ -40,7 +39,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
40
39
}
41
40
42
41
let nodeName = vnode . type ,
43
- attributes = vnode . props ,
42
+ props = vnode . props ,
44
43
isComponent = false ;
45
44
context = context || { } ;
46
45
opts = opts || { } ;
@@ -60,8 +59,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
60
59
nodeName = getComponentName ( nodeName ) ;
61
60
}
62
61
else {
63
- let props = vnode . props , //props = getNodeProps(vnode),
64
- rendered ;
62
+ let rendered ;
65
63
66
64
if ( ! nodeName . prototype || typeof nodeName . prototype . render !== 'function' ) {
67
65
// stateless functional components
@@ -90,23 +88,23 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
90
88
// render JSX to HTML
91
89
let s = '' , html ;
92
90
93
- if ( attributes ) {
94
- let attrs = Object . keys ( attributes ) ;
91
+ if ( props ) {
92
+ let attrs = Object . keys ( props ) ;
95
93
96
94
// allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)
97
95
if ( opts && opts . sortAttributes === true ) attrs . sort ( ) ;
98
96
99
97
for ( let i = 0 ; i < attrs . length ; i ++ ) {
100
98
let name = attrs [ i ] ,
101
- v = attributes [ name ] ;
99
+ v = props [ name ] ;
102
100
if ( name === 'children' ) continue ;
103
101
104
102
if ( name . match ( / [ \s \n \\ / = ' " \0 < > ] / ) ) continue ;
105
103
106
104
if ( ! ( opts && opts . allAttributes ) && ( name === 'key' || name === 'ref' ) ) continue ;
107
105
108
106
if ( name === 'className' ) {
109
- if ( attributes . class ) continue ;
107
+ if ( props . class ) continue ;
110
108
name = 'class' ;
111
109
}
112
110
else if ( isSvgMode && name . match ( / ^ x l i n k : ? ./ ) ) {
@@ -163,7 +161,7 @@ function renderToString(vnode, context, opts, inner, isSvgMode) {
163
161
}
164
162
s += html ;
165
163
}
166
- else if ( vnode . props && getChildren ( children = [ ] , vnode . props . children ) . length ) {
164
+ else if ( props && getChildren ( children = [ ] , props . children ) . length ) {
167
165
let hasLarge = pretty && ~ s . indexOf ( '\n' ) ;
168
166
for ( let i = 0 ; i < children . length ; i ++ ) {
169
167
let child = children [ i ] ;
0 commit comments