preact-render-to-string 5.1.10 → 5.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.js CHANGED
@@ -1,4 +1,11 @@
1
- import { encodeEntities, indent, isLargeString, styleObjToCss, assign, getChildren } from './util';
1
+ import {
2
+ encodeEntities,
3
+ indent,
4
+ isLargeString,
5
+ styleObjToCss,
6
+ assign,
7
+ getChildren
8
+ } from './util';
2
9
  import { options, Fragment, createElement } from 'preact';
3
10
 
4
11
  const SHALLOW = { shallow: true };
@@ -10,7 +17,6 @@ const VOID_ELEMENTS = /^(area|base|br|col|embed|hr|img|input|link|meta|param|sou
10
17
 
11
18
  const noop = () => {};
12
19
 
13
-
14
20
  /** Render Preact JSX + Components to an HTML string.
15
21
  * @name render
16
22
  * @function
@@ -24,7 +30,6 @@ const noop = () => {};
24
30
  */
25
31
  renderToString.render = renderToString;
26
32
 
27
-
28
33
  /** Only render elements, leaving Components inline as `<ComponentName ... />`.
29
34
  * This method is just a convenience alias for `render(vnode, context, { shallow:true })`
30
35
  * @name shallow
@@ -34,10 +39,9 @@ renderToString.render = renderToString;
34
39
  */
35
40
  let shallowRender = (vnode, context) => renderToString(vnode, context, SHALLOW);
36
41
 
37
-
38
42
  /** The default export is an alias of `render()`. */
39
43
  function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
40
- if (vnode==null || typeof vnode==='boolean') {
44
+ if (vnode == null || typeof vnode === 'boolean') {
41
45
  return '';
42
46
  }
43
47
 
@@ -53,33 +57,40 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
53
57
  opts = opts || {};
54
58
 
55
59
  let pretty = opts.pretty,
56
- indentChar = pretty && typeof pretty==='string' ? pretty : '\t';
60
+ indentChar = pretty && typeof pretty === 'string' ? pretty : '\t';
57
61
 
58
62
  // #text nodes
59
- if (typeof vnode!=='object' && !nodeName) {
63
+ if (typeof vnode !== 'object' && !nodeName) {
60
64
  return encodeEntities(vnode);
61
65
  }
62
66
 
63
67
  // components
64
- if (typeof nodeName==='function') {
68
+ if (typeof nodeName === 'function') {
65
69
  isComponent = true;
66
- if (opts.shallow && (inner || opts.renderRootComponent===false)) {
70
+ if (opts.shallow && (inner || opts.renderRootComponent === false)) {
67
71
  nodeName = getComponentName(nodeName);
68
- }
69
- else if (nodeName===Fragment) {
72
+ } else if (nodeName === Fragment) {
70
73
  let rendered = '';
71
74
  let children = [];
72
75
  getChildren(children, vnode.props.children);
73
76
 
74
77
  for (let i = 0; i < children.length; i++) {
75
- rendered += (i > 0 && pretty ? '\n' : '') + renderToString(children[i], context, opts, opts.shallowHighOrder!==false, isSvgMode, selectValue);
78
+ rendered +=
79
+ (i > 0 && pretty ? '\n' : '') +
80
+ renderToString(
81
+ children[i],
82
+ context,
83
+ opts,
84
+ opts.shallowHighOrder !== false,
85
+ isSvgMode,
86
+ selectValue
87
+ );
76
88
  }
77
89
  return rendered;
78
- }
79
- else {
90
+ } else {
80
91
  let rendered;
81
92
 
82
- let c = vnode.__c = {
93
+ let c = (vnode.__c = {
83
94
  __v: vnode,
84
95
  context,
85
96
  props: vnode.props,
@@ -88,26 +99,41 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
88
99
  forceUpdate: noop,
89
100
  // hooks
90
101
  __h: []
91
- };
102
+ });
92
103
 
93
- // options.render
104
+ // options._diff
105
+ if (options.__b) options.__b(vnode);
106
+
107
+ // options._render
94
108
  if (options.__r) options.__r(vnode);
95
109
 
96
- if (!nodeName.prototype || typeof nodeName.prototype.render!=='function') {
110
+ if (
111
+ !nodeName.prototype ||
112
+ typeof nodeName.prototype.render !== 'function'
113
+ ) {
97
114
  // Necessary for createContext api. Setting this property will pass
98
115
  // the context value as `this.context` just for this component.
99
116
  let cxType = nodeName.contextType;
100
117
  let provider = cxType && context[cxType.__c];
101
- let cctx = cxType != null ? (provider ? provider.props.value : cxType.__) : context;
118
+ let cctx =
119
+ cxType != null
120
+ ? provider
121
+ ? provider.props.value
122
+ : cxType.__
123
+ : context;
102
124
 
103
125
  // stateless functional components
104
126
  rendered = nodeName.call(vnode.__c, props, cctx);
105
- }
106
- else {
127
+ } else {
107
128
  // class-based components
108
129
  let cxType = nodeName.contextType;
109
130
  let provider = cxType && context[cxType.__c];
110
- let cctx = cxType != null ? (provider ? provider.props.value : cxType.__) : context;
131
+ let cctx =
132
+ cxType != null
133
+ ? provider
134
+ ? provider.props.value
135
+ : cxType.__
136
+ : context;
111
137
 
112
138
  // c = new nodeName(props, context);
113
139
  c = vnode.__c = new nodeName(props, cctx);
@@ -115,22 +141,29 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
115
141
  // turn off stateful re-rendering:
116
142
  c._dirty = c.__d = true;
117
143
  c.props = props;
118
- if (c.state==null) c.state = {};
144
+ if (c.state == null) c.state = {};
119
145
 
120
- if (c._nextState==null && c.__s==null) {
146
+ if (c._nextState == null && c.__s == null) {
121
147
  c._nextState = c.__s = c.state;
122
148
  }
123
149
 
124
150
  c.context = cctx;
125
- if (nodeName.getDerivedStateFromProps) c.state = assign(assign({}, c.state), nodeName.getDerivedStateFromProps(c.props, c.state));
151
+ if (nodeName.getDerivedStateFromProps)
152
+ c.state = assign(
153
+ assign({}, c.state),
154
+ nodeName.getDerivedStateFromProps(c.props, c.state)
155
+ );
126
156
  else if (c.componentWillMount) {
127
157
  c.componentWillMount();
128
158
 
129
159
  // If the user called setState in cWM we need to flush pending,
130
160
  // state updates. This is the same behaviour in React.
131
- c.state = c._nextState !== c.state
132
- ? c._nextState : c.__s!==c.state
133
- ? c.__s : c.state;
161
+ c.state =
162
+ c._nextState !== c.state
163
+ ? c._nextState
164
+ : c.__s !== c.state
165
+ ? c.__s
166
+ : c.state;
134
167
  }
135
168
 
136
169
  rendered = c.render(c.props, c.state, c.context);
@@ -140,45 +173,61 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
140
173
  context = assign(assign({}, context), c.getChildContext());
141
174
  }
142
175
 
143
- return renderToString(rendered, context, opts, opts.shallowHighOrder!==false, isSvgMode, selectValue);
176
+ return renderToString(
177
+ rendered,
178
+ context,
179
+ opts,
180
+ opts.shallowHighOrder !== false,
181
+ isSvgMode,
182
+ selectValue
183
+ );
144
184
  }
145
185
  }
146
186
 
147
187
  // render JSX to HTML
148
- let s = '', propChildren, html;
188
+ let s = '',
189
+ propChildren,
190
+ html;
149
191
 
150
192
  if (props) {
151
193
  let attrs = Object.keys(props);
152
194
 
153
195
  // allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)
154
- if (opts && opts.sortAttributes===true) attrs.sort();
196
+ if (opts && opts.sortAttributes === true) attrs.sort();
155
197
 
156
- for (let i=0; i<attrs.length; i++) {
198
+ for (let i = 0; i < attrs.length; i++) {
157
199
  let name = attrs[i],
158
200
  v = props[name];
159
- if (name==='children') {
201
+ if (name === 'children') {
160
202
  propChildren = v;
161
203
  continue;
162
204
  }
163
205
 
164
206
  if (name.match(/[\s\n\\/='"\0<>]/)) continue;
165
207
 
166
- if (!(opts && opts.allAttributes) && (name==='key' || name==='ref' || name==='__self' || name==='__source')) continue;
208
+ if (
209
+ !(opts && opts.allAttributes) &&
210
+ (name === 'key' ||
211
+ name === 'ref' ||
212
+ name === '__self' ||
213
+ name === '__source' ||
214
+ name === 'defaultValue')
215
+ )
216
+ continue;
167
217
 
168
- if (name==='className') {
218
+ if (name === 'className') {
169
219
  if (props.class) continue;
170
220
  name = 'class';
171
- }
172
- else if (isSvgMode && name.match(/^xlink:?./)) {
221
+ } else if (isSvgMode && name.match(/^xlink:?./)) {
173
222
  name = name.toLowerCase().replace(/^xlink:?/, 'xlink:');
174
223
  }
175
224
 
176
- if (name==='htmlFor') {
225
+ if (name === 'htmlFor') {
177
226
  if (props.for) continue;
178
227
  name = 'for';
179
228
  }
180
229
 
181
- if (name==='style' && v && typeof v==='object') {
230
+ if (name === 'style' && v && typeof v === 'object') {
182
231
  v = styleObjToCss(v);
183
232
  }
184
233
 
@@ -188,21 +237,21 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
188
237
  v = String(v);
189
238
  }
190
239
 
191
- let hooked = opts.attributeHook && opts.attributeHook(name, v, context, opts, isComponent);
192
- if (hooked || hooked==='') {
240
+ let hooked =
241
+ opts.attributeHook &&
242
+ opts.attributeHook(name, v, context, opts, isComponent);
243
+ if (hooked || hooked === '') {
193
244
  s += hooked;
194
245
  continue;
195
246
  }
196
247
 
197
- if (name==='dangerouslySetInnerHTML') {
248
+ if (name === 'dangerouslySetInnerHTML') {
198
249
  html = v && v.__html;
199
- }
200
- else if (nodeName === 'textarea' && name === 'value') {
250
+ } else if (nodeName === 'textarea' && name === 'value') {
201
251
  // <textarea value="a&b"> --> <textarea>a&amp;b</textarea>
202
252
  propChildren = v;
203
- }
204
- else if ((v || v===0 || v==='') && typeof v!=='function') {
205
- if (v===true || v==='') {
253
+ } else if ((v || v === 0 || v === '') && typeof v !== 'function') {
254
+ if (v === true || v === '') {
206
255
  v = name;
207
256
  // in non-xml mode, allow boolean attributes
208
257
  if (!opts || !opts.xml) {
@@ -211,12 +260,11 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
211
260
  }
212
261
  }
213
262
 
214
- if (name==='value') {
215
- if (nodeName==='select') {
263
+ if (name === 'value') {
264
+ if (nodeName === 'select') {
216
265
  selectValue = v;
217
266
  continue;
218
- }
219
- else if (nodeName==='option' && selectValue==v) {
267
+ } else if (nodeName === 'option' && selectValue == v) {
220
268
  s += ` selected`;
221
269
  }
222
270
  }
@@ -228,16 +276,17 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
228
276
  // account for >1 multiline attribute
229
277
  if (pretty) {
230
278
  let sub = s.replace(/^\n\s*/, ' ');
231
- if (sub!==s && !~sub.indexOf('\n')) s = sub;
279
+ if (sub !== s && !~sub.indexOf('\n')) s = sub;
232
280
  else if (pretty && ~s.indexOf('\n')) s += '\n';
233
281
  }
234
282
 
235
283
  s = `<${nodeName}${s}>`;
236
- if (String(nodeName).match(/[\s\n\\/='"\0<>]/)) throw new Error(`${nodeName} is not a valid HTML tag name in ${s}`);
237
-
238
- let isVoid = String(nodeName).match(VOID_ELEMENTS) || (opts.voidElements && String(nodeName).match(opts.voidElements));
239
- if (isVoid) s = s.replace(/>$/, ' />');
284
+ if (String(nodeName).match(/[\s\n\\/='"\0<>]/))
285
+ throw new Error(`${nodeName} is not a valid HTML tag name in ${s}`);
240
286
 
287
+ let isVoid =
288
+ String(nodeName).match(VOID_ELEMENTS) ||
289
+ (opts.voidElements && String(nodeName).match(opts.voidElements));
241
290
  let pieces = [];
242
291
 
243
292
  let children;
@@ -247,44 +296,56 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
247
296
  html = '\n' + indentChar + indent(html, indentChar);
248
297
  }
249
298
  s += html;
250
- }
251
- else if (propChildren != null && getChildren(children = [], propChildren).length) {
299
+ } else if (
300
+ propChildren != null &&
301
+ getChildren((children = []), propChildren).length
302
+ ) {
252
303
  let hasLarge = pretty && ~s.indexOf('\n');
253
304
  let lastWasText = false;
254
305
 
255
- for (let i=0; i<children.length; i++) {
306
+ for (let i = 0; i < children.length; i++) {
256
307
  let child = children[i];
257
308
 
258
- if (child!=null && child!==false) {
259
- let childSvgMode = nodeName==='svg' ? true : nodeName==='foreignObject' ? false : isSvgMode,
260
- ret = renderToString(child, context, opts, true, childSvgMode, selectValue);
309
+ if (child != null && child !== false) {
310
+ let childSvgMode =
311
+ nodeName === 'svg'
312
+ ? true
313
+ : nodeName === 'foreignObject'
314
+ ? false
315
+ : isSvgMode,
316
+ ret = renderToString(
317
+ child,
318
+ context,
319
+ opts,
320
+ true,
321
+ childSvgMode,
322
+ selectValue
323
+ );
261
324
 
262
325
  if (pretty && !hasLarge && isLargeString(ret)) hasLarge = true;
263
326
 
264
327
  // Skip if we received an empty string
265
328
  if (ret) {
266
329
  if (pretty) {
267
- let isText = ret.length > 0 && ret[0]!='<';
330
+ let isText = ret.length > 0 && ret[0] != '<';
268
331
 
269
332
  // We merge adjacent text nodes, otherwise each piece would be printed
270
333
  // on a new line.
271
334
  if (lastWasText && isText) {
272
- pieces[pieces.length -1] += ret;
273
- }
274
- else {
335
+ pieces[pieces.length - 1] += ret;
336
+ } else {
275
337
  pieces.push(ret);
276
338
  }
277
339
 
278
340
  lastWasText = isText;
279
- }
280
- else {
341
+ } else {
281
342
  pieces.push(ret);
282
343
  }
283
344
  }
284
345
  }
285
346
  }
286
347
  if (pretty && hasLarge) {
287
- for (let i=pieces.length; i--; ) {
348
+ for (let i = pieces.length; i--; ) {
288
349
  pieces[i] = '\n' + indentChar + indent(pieces[i], indentChar);
289
350
  }
290
351
  }
@@ -292,12 +353,13 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
292
353
 
293
354
  if (pieces.length) {
294
355
  s += pieces.join('');
295
- }
296
- else if (opts && opts.xml) {
297
- return s.substring(0, s.length-1) + ' />';
356
+ } else if (opts && opts.xml) {
357
+ return s.substring(0, s.length - 1) + ' />';
298
358
  }
299
359
 
300
- if (!isVoid) {
360
+ if (isVoid && !children) {
361
+ s = s.replace(/>$/, ' />');
362
+ } else {
301
363
  if (pretty && ~s.indexOf('\n')) s += '\n';
302
364
  s += `</${nodeName}>`;
303
365
  }
@@ -306,7 +368,11 @@ function renderToString(vnode, context, opts, inner, isSvgMode, selectValue) {
306
368
  }
307
369
 
308
370
  function getComponentName(component) {
309
- return component.displayName || component!==Function && component.name || getFallbackComponentName(component);
371
+ return (
372
+ component.displayName ||
373
+ (component !== Function && component.name) ||
374
+ getFallbackComponentName(component)
375
+ );
310
376
  }
311
377
 
312
378
  function getFallbackComponentName(component) {
@@ -315,14 +381,14 @@ function getFallbackComponentName(component) {
315
381
  if (!name) {
316
382
  // search for an existing indexed name for the given component:
317
383
  let index = -1;
318
- for (let i=UNNAMED.length; i--; ) {
319
- if (UNNAMED[i]===component) {
384
+ for (let i = UNNAMED.length; i--; ) {
385
+ if (UNNAMED[i] === component) {
320
386
  index = i;
321
387
  break;
322
388
  }
323
389
  }
324
390
  // not found, create a new indexed name:
325
- if (index<0) {
391
+ if (index < 0) {
326
392
  index = UNNAMED.push(component) - 1;
327
393
  }
328
394
  name = `UnnamedComponent${index}`;
package/src/jsx.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { VNode } from 'preact';
2
2
 
3
3
  interface Options {
4
- jsx?: boolean;
5
- xml?: boolean;
6
- functions?: boolean
7
- functionNames?: boolean,
8
- skipFalseAttributes?: boolean
9
- pretty?: boolean | string;
4
+ jsx?: boolean;
5
+ xml?: boolean;
6
+ functions?: boolean;
7
+ functionNames?: boolean;
8
+ skipFalseAttributes?: boolean;
9
+ pretty?: boolean | string;
10
10
  }
11
11
 
12
- export function render(vnode: VNode, context?: any, options?: Options):string;
12
+ export function render(vnode: VNode, context?: any, options?: Options): string;
13
13
  export default render;
package/src/jsx.js CHANGED
@@ -3,45 +3,53 @@ import renderToString from './index';
3
3
  import { indent, encodeEntities, assign } from './util';
4
4
  import prettyFormat from 'pretty-format';
5
5
 
6
-
7
6
  // we have to patch in Array support, Possible issue in npm.im/pretty-format
8
7
  let preactPlugin = {
9
8
  test(object) {
10
- return object && typeof object==='object' && 'type' in object && 'props' in object && 'key' in object;
9
+ return (
10
+ object &&
11
+ typeof object === 'object' &&
12
+ 'type' in object &&
13
+ 'props' in object &&
14
+ 'key' in object
15
+ );
11
16
  },
12
17
  print(val, print, indent) {
13
18
  return renderToString(val, preactPlugin.context, preactPlugin.opts, true);
14
19
  }
15
20
  };
16
21
 
17
-
18
22
  let prettyFormatOpts = {
19
23
  plugins: [preactPlugin]
20
24
  };
21
25
 
22
-
23
26
  function attributeHook(name, value, context, opts, isComponent) {
24
27
  let type = typeof value;
25
-
28
+
26
29
  // Use render-to-string's built-in handling for these properties
27
- if (name==='dangerouslySetInnerHTML') return false;
30
+ if (name === 'dangerouslySetInnerHTML') return false;
28
31
 
29
32
  // always skip null & undefined values, skip false DOM attributes, skip functions if told to
30
- if (value==null || (type==='function' && !opts.functions)) return '';
33
+ if (value == null || (type === 'function' && !opts.functions)) return '';
31
34
 
32
- if (opts.skipFalseAttributes && !isComponent && (value===false || ((name==='class' || name==='style') && value===''))) return '';
35
+ if (
36
+ opts.skipFalseAttributes &&
37
+ !isComponent &&
38
+ (value === false ||
39
+ ((name === 'class' || name === 'style') && value === ''))
40
+ )
41
+ return '';
33
42
 
34
- let indentChar = typeof opts.pretty==='string' ? opts.pretty : '\t';
35
- if (type!=='string') {
36
- if (type==='function' && !opts.functionNames) {
43
+ let indentChar = typeof opts.pretty === 'string' ? opts.pretty : '\t';
44
+ if (type !== 'string') {
45
+ if (type === 'function' && !opts.functionNames) {
37
46
  value = 'Function';
38
- }
39
- else {
47
+ } else {
40
48
  preactPlugin.context = context;
41
49
  preactPlugin.opts = opts;
42
50
  value = prettyFormat(value, prettyFormatOpts);
43
51
  if (~value.indexOf('\n')) {
44
- value = `${indent('\n'+value, indentChar)}\n`;
52
+ value = `${indent('\n' + value, indentChar)}\n`;
45
53
  }
46
54
  }
47
55
  return indent(`\n${name}={${value}}`, indentChar);
@@ -49,7 +57,6 @@ function attributeHook(name, value, context, opts, isComponent) {
49
57
  return `\n${indentChar}${name}="${encodeEntities(value)}"`;
50
58
  }
51
59
 
52
-
53
60
  let defaultOpts = {
54
61
  attributeHook,
55
62
  jsx: true,
@@ -60,7 +67,6 @@ let defaultOpts = {
60
67
  pretty: ' '
61
68
  };
62
69
 
63
-
64
70
  function renderToJsxString(vnode, context, opts, inner) {
65
71
  opts = assign(assign({}, defaultOpts), opts || {});
66
72
  return renderToString(vnode, context, opts, inner);
package/src/polyfills.js CHANGED
@@ -1,7 +1,8 @@
1
- if (typeof Symbol!=='function') {
1
+ if (typeof Symbol !== 'function') {
2
2
  let c = 0;
3
- Symbol = function(s) { // eslint-disable-line
3
+ // eslint-disable-next-line
4
+ Symbol = function (s) {
4
5
  return `@@${s}${++c}`;
5
6
  };
6
- Symbol.for = s => `@@${s}`;
7
+ Symbol.for = (s) => `@@${s}`;
7
8
  }
package/src/util.js CHANGED
@@ -1,15 +1,30 @@
1
1
  // DOM properties that should NOT have "px" added when numeric
2
2
  export const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;
3
3
 
4
- export let encodeEntities = s => String(s)
5
- .replace(/&/g, '&amp;')
6
- .replace(/</g, '&lt;')
7
- .replace(/>/g, '&gt;')
8
- .replace(/"/g, '&quot;');
4
+ export function encodeEntities(s) {
5
+ if (typeof s !== 'string') s = String(s);
6
+ let out = '';
7
+ for (let i = 0; i < s.length; i++) {
8
+ let ch = s[i];
9
+ // prettier-ignore
10
+ switch (ch) {
11
+ case '<': out += '&lt;'; break;
12
+ case '>': out += '&gt;'; break;
13
+ case '"': out += '&quot;'; break;
14
+ case '&': out += '&amp;'; break;
15
+ default: out += ch;
16
+ }
17
+ }
18
+ return out;
19
+ }
9
20
 
10
- export let indent = (s, char) => String(s).replace(/(\n+)/g, '$1' + (char || '\t'));
21
+ export let indent = (s, char) =>
22
+ String(s).replace(/(\n+)/g, '$1' + (char || '\t'));
11
23
 
12
- export let isLargeString = (s, length, ignoreLines) => (String(s).length>(length || 40) || (!ignoreLines && String(s).indexOf('\n')!==-1) || String(s).indexOf('<')!==-1);
24
+ export let isLargeString = (s, length, ignoreLines) =>
25
+ String(s).length > (length || 40) ||
26
+ (!ignoreLines && String(s).indexOf('\n') !== -1) ||
27
+ String(s).indexOf('<') !== -1;
13
28
 
14
29
  const JS_TO_CSS = {};
15
30
 
@@ -18,13 +33,17 @@ export function styleObjToCss(s) {
18
33
  let str = '';
19
34
  for (let prop in s) {
20
35
  let val = s[prop];
21
- if (val!=null) {
36
+ if (val != null) {
22
37
  if (str) str += ' ';
23
38
  // str += jsToCss(prop);
24
- str += prop[0]=='-' ? prop : (JS_TO_CSS[prop] || (JS_TO_CSS[prop] = prop.replace(/([A-Z])/g,'-$1').toLowerCase()));
39
+ str +=
40
+ prop[0] == '-'
41
+ ? prop
42
+ : JS_TO_CSS[prop] ||
43
+ (JS_TO_CSS[prop] = prop.replace(/([A-Z])/g, '-$1').toLowerCase());
25
44
  str += ': ';
26
45
  str += val;
27
- if (typeof val==='number' && IS_NON_DIMENSIONAL.test(prop)===false) {
46
+ if (typeof val === 'number' && IS_NON_DIMENSIONAL.test(prop) === false) {
28
47
  str += 'px';
29
48
  }
30
49
  str += ';';
@@ -55,8 +74,7 @@ export function assign(obj, props) {
55
74
  export function getChildren(accumulator, children) {
56
75
  if (Array.isArray(children)) {
57
76
  children.reduce(getChildren, accumulator);
58
- }
59
- else if (children!=null && children!==false) {
77
+ } else if (children != null && children !== false) {
60
78
  accumulator.push(children);
61
79
  }
62
80
  return accumulator;