├── .babelrc ├── .editorconfig ├── .eslintrc ├── .gitignore ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── package-lock.json ├── package.json ├── src ├── helpers │ ├── add-import.js │ ├── ast │ │ ├── flatten-expressions.js │ │ ├── statements-with-return-last.js │ │ ├── to-function-call.js │ │ ├── to-reference.js │ │ ├── to-statement.js │ │ └── to-string.js │ ├── attributes.js │ ├── build-children.js │ ├── clean-text.js │ ├── collect-imports.js │ ├── completion-records.js │ ├── element-close-call.js │ ├── element-open-call.js │ ├── extract-expressions.js │ ├── extract-open-arguments.js │ ├── fast-root.js │ ├── hoist.js │ ├── idom-method.js │ ├── inject.js │ ├── inline-expressions.js │ ├── is-component.js │ ├── is-literal-or-special.js │ ├── is-returned.js │ ├── last.js │ ├── module-source.js │ ├── patch-roots.js │ ├── resolve-path.js │ ├── root-jsx.js │ ├── runtime │ │ ├── has-own.js │ │ ├── jsx-wrapper.js │ │ ├── render-arbitrary.js │ │ └── spread-attribute.js │ └── uuid.js ├── index.js └── messages.js ├── test.js └── test ├── fixtures ├── arrow-return │ ├── explicit │ │ ├── actual.js │ │ └── expected.js │ └── implicit │ │ ├── actual.js │ │ └── expected.js ├── attributes │ ├── computed-expression │ │ ├── actual.js │ │ └── expected.js │ ├── computed-false │ │ ├── actual.js │ │ └── expected.js │ ├── computed-infinity │ │ ├── actual.js │ │ └── expected.js │ ├── computed-nan │ │ ├── actual.js │ │ └── expected.js │ ├── computed-null │ │ ├── actual.js │ │ └── expected.js │ ├── computed-number │ │ ├── actual.js │ │ └── expected.js │ ├── computed-prop │ │ ├── actual.js │ │ └── expected.js │ ├── computed-string │ │ ├── actual.js │ │ └── expected.js │ ├── computed-true │ │ ├── actual.js │ │ └── expected.js │ ├── computed-undefined │ │ ├── actual.js │ │ └── expected.js │ ├── computed-void │ │ ├── actual.js │ │ └── expected.js │ ├── computed │ │ ├── actual.js │ │ └── expected.js │ ├── element-in-attribute │ │ ├── actual.js │ │ └── expected.js │ ├── implicit-true │ │ ├── actual.js │ │ └── expected.js │ ├── jsx-element-computed-attr │ │ ├── actual.js │ │ └── expected.js │ ├── jsx-element-computed-child │ │ ├── actual.js │ │ └── expected.js │ ├── literal-require-statics-key │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── literal-with-key │ │ ├── actual.js │ │ └── expected.js │ ├── literal │ │ ├── actual.js │ │ └── expected.js │ └── nested-element-in-attribute │ │ ├── actual.js │ │ └── expected.js ├── call-expression-defer │ └── wrapper │ │ ├── attributes │ │ ├── actual.js │ │ └── expected.js │ │ ├── call │ │ ├── actual.js │ │ └── expected.js │ │ ├── compound │ │ └── eval.js │ │ ├── conditional │ │ ├── actual.js │ │ └── expected.js │ │ ├── inner-call │ │ ├── actual.js │ │ └── expected.js │ │ ├── logical │ │ ├── actual.js │ │ └── expected.js │ │ ├── member-call │ │ ├── actual.js │ │ └── expected.js │ │ ├── mutated-params │ │ ├── call │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── conditional │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── logical │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── member-call │ │ │ ├── actual.js │ │ │ └── expected.js │ │ └── sequence │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── optimizations │ │ ├── literal-args │ │ │ ├── actual.js │ │ │ └── expected.js │ │ └── single-arg │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── sequence │ │ ├── actual.js │ │ └── expected.js │ │ └── spread │ │ ├── actual.js │ │ └── expected.js ├── comment │ ├── child │ │ ├── actual.js │ │ └── expected.js │ └── inline │ │ ├── actual.js │ │ └── expected.js ├── components │ ├── component │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── element │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ └── member-expression-tag │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json ├── conditional-optimizations │ └── eval.js ├── eager-expressions │ ├── non-root │ │ ├── actual.js │ │ └── expected.js │ ├── root-nested-function │ │ ├── actual.js │ │ └── expected.js │ └── root │ │ ├── actual.js │ │ └── expected.js ├── element │ ├── component-custom-element │ │ ├── actual.js │ │ └── expected.js │ ├── member-expression-tag │ │ ├── actual.js │ │ └── expected.js │ ├── nested │ │ ├── actual.js │ │ └── expected.js │ └── root │ │ ├── actual.js │ │ └── expected.js ├── error │ └── namespace │ │ ├── attribute │ │ ├── actual.js │ │ └── options.json │ │ ├── element │ │ ├── actual.js │ │ └── options.json │ │ └── namespace-attributes-element-namespace │ │ ├── actual.js │ │ └── options.json ├── expression-children │ ├── 0 │ │ ├── actual.js │ │ └── expected.js │ ├── 1 │ │ ├── actual.js │ │ └── expected.js │ ├── 2 │ │ ├── actual.js │ │ └── expected.js │ ├── 3 │ │ ├── actual.js │ │ └── expected.js │ ├── 4 │ │ ├── actual.js │ │ └── expected.js │ ├── 5 │ │ ├── actual.js │ │ └── expected.js │ ├── 6 │ │ ├── actual.js │ │ └── expected.js │ ├── 7 │ │ ├── actual.js │ │ └── expected.js │ ├── 8 │ │ ├── actual.js │ │ └── expected.js │ ├── 9 │ │ ├── actual.js │ │ └── expected.js │ ├── 10 │ │ ├── actual.js │ │ └── expected.js │ ├── 11 │ │ ├── actual.js │ │ └── expected.js │ ├── 12 │ │ ├── actual.js │ │ └── expected.js │ ├── 13 │ │ ├── actual.js │ │ └── expected.js │ ├── 14 │ │ ├── actual.js │ │ └── expected.js │ ├── 15 │ │ ├── actual.js │ │ └── expected.js │ ├── if-then │ │ ├── 0 │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── 1 │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── conditional-expression │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── logical-expression-sequence-expression-bad │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── logical-expression-sequence-expression-good │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── logical-expression │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── sequence-expression-bad │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── sequence-expression-good │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── sequence-expression-logical-expression-bad │ │ │ ├── actual.js │ │ │ └── expected.js │ │ └── sequence-expression-logical-expression-good │ │ │ ├── actual.js │ │ │ └── expected.js │ ├── infinity │ │ ├── actual.js │ │ └── expected.js │ ├── key-expression │ │ ├── actual.js │ │ └── expected.js │ ├── nan │ │ ├── actual.js │ │ └── expected.js │ ├── null │ │ ├── actual.js │ │ └── expected.js │ ├── number │ │ ├── actual.js │ │ └── expected.js │ ├── string │ │ ├── actual.js │ │ └── expected.js │ ├── undefined │ │ ├── actual.js │ │ └── expected.js │ └── void │ │ ├── actual.js │ │ └── expected.js ├── expression │ ├── each │ │ ├── actual.js │ │ └── expected.js │ ├── invocation │ │ ├── actual.js │ │ └── expected.js │ ├── nested-invocation │ │ ├── actual.js │ │ └── expected.js │ ├── nested-object-property │ │ ├── actual.js │ │ └── expected.js │ ├── nested-variable │ │ ├── actual.js │ │ └── expected.js │ ├── number-literal │ │ ├── actual.js │ │ └── expected.js │ ├── object-property │ │ ├── actual.js │ │ └── expected.js │ ├── text-literal │ │ ├── actual.js │ │ └── expected.js │ └── variable │ │ ├── actual.js │ │ └── expected.js ├── fast-root │ ├── comments │ │ ├── disable-inline │ │ │ ├── child-funciton-level │ │ │ │ ├── actual.js │ │ │ │ ├── expected.js │ │ │ │ └── options.json │ │ │ ├── child-level │ │ │ │ ├── actual.js │ │ │ │ ├── expected.js │ │ │ │ └── options.json │ │ │ ├── function-level │ │ │ │ ├── actual.js │ │ │ │ ├── expected.js │ │ │ │ └── options.json │ │ │ ├── no-comment │ │ │ │ ├── actual.js │ │ │ │ ├── expected.js │ │ │ │ └── options.json │ │ │ └── root-level │ │ │ │ ├── actual.js │ │ │ │ ├── expected.js │ │ │ │ └── options.json │ │ └── enable-inline │ │ │ ├── child-funciton-level │ │ │ ├── actual.js │ │ │ ├── expected.js │ │ │ └── options.json │ │ │ ├── child-level │ │ │ ├── actual.js │ │ │ ├── expected.js │ │ │ └── options.json │ │ │ ├── function-level │ │ │ ├── actual.js │ │ │ ├── expected.js │ │ │ └── options.json │ │ │ ├── no-comment │ │ │ ├── actual.js │ │ │ ├── expected.js │ │ │ └── options.json │ │ │ └── root-level │ │ │ ├── actual.js │ │ │ ├── expected.js │ │ │ └── options.json │ └── true │ │ ├── attribute-nested-attribute │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── attribute │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── element │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── logical │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── nested-attribute-nested-attribute │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── nested-attribute │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── nested-child-element │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── nested-element │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── nested-nested-child-element │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── secondary-element │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ └── sequence │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json ├── idom-methods │ ├── global │ │ ├── actual.js │ │ └── expected.js │ ├── import-namespace-with-prefix │ │ ├── actual.js │ │ └── expected.js │ ├── import-specifier │ │ ├── actual.js │ │ └── expected.js │ └── require │ │ ├── actual.js │ │ └── expected.js ├── inline-expressions │ ├── assigned-conditionally │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── assigned-staticly │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── call-hoisted │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── call-iife │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── call │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── eager-children │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── element-with-inline │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── element │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── function-nested-elements │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── function-param │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── global │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── hoisted │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── inline-in-wrapper │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── literal │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── nested-elements │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── undefined │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── wrapper-with-eager-expressions │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ └── wrapper │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json ├── issues │ ├── 37 │ │ ├── actual.js │ │ └── expected.js │ ├── 41 │ │ ├── actual.js │ │ └── expected.js │ └── 96 │ │ ├── actual.js │ │ └── expected.js ├── key │ ├── mutate │ │ ├── jsx-in-attribute-updates-key │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── nested-other-attr-updates-key │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── other-attr-updates-key │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── other-attr │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── spread-attributes-member-mutated-key │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── spread-attributes-mutated-key │ │ │ ├── actual.js │ │ │ └── expected.js │ │ ├── wrapper-other-attr-updates-key │ │ │ ├── actual.js │ │ │ └── expected.js │ │ └── wrapper-spread-attribute-updates-key │ │ │ ├── actual.js │ │ │ └── expected.js │ ├── nested-object-property │ │ ├── actual.js │ │ └── expected.js │ ├── nested-string-literal │ │ ├── actual.js │ │ └── expected.js │ ├── nested-string │ │ ├── actual.js │ │ └── expected.js │ ├── nexted-number-literal │ │ ├── actual.js │ │ └── expected.js │ ├── nexted-variable │ │ ├── actual.js │ │ └── expected.js │ ├── number-literal │ │ ├── actual.js │ │ └── expected.js │ ├── object-property │ │ ├── actual.js │ │ └── expected.js │ ├── string-literal │ │ ├── actual.js │ │ └── expected.js │ ├── string │ │ ├── actual.js │ │ └── expected.js │ └── variable │ │ ├── actual.js │ │ └── expected.js ├── module-source │ ├── absolute │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── global │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ └── relative │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json ├── namespace-attributes │ └── attribute │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json ├── patch-root │ ├── 69 │ │ ├── actual.js │ │ └── expected.js │ ├── class │ │ ├── actual.js │ │ └── expected.js │ ├── extracted-render │ │ ├── actual.js │ │ └── expected.js │ ├── fast-root │ │ ├── actual.js │ │ └── expected.js │ ├── import-specifier │ │ ├── actual.js │ │ └── expected.js │ ├── import-wildcard │ │ ├── actual.js │ │ └── expected.js │ ├── module-source-import-specifier │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── module-source-import-wildcard │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── no-import │ │ ├── actual.js │ │ └── expected.js │ ├── object │ │ ├── actual.js │ │ └── expected.js │ └── requires-root-node │ │ ├── actual.js │ │ └── expected.js ├── program │ ├── element │ │ ├── actual.js │ │ └── expected.js │ ├── expression-children │ │ ├── actual.js │ │ └── expected.js │ └── hoist │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json ├── runtime │ └── module │ │ ├── expression-child │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── spread │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ ├── wrapper-eager │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ │ └── wrapper │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json ├── self-closing-element │ ├── nested-attribute │ │ ├── actual.js │ │ └── expected.js │ ├── nested-self-closing │ │ ├── actual.js │ │ └── expected.js │ ├── root-attribute │ │ ├── actual.js │ │ └── expected.js │ └── root │ │ ├── actual.js │ │ └── expected.js ├── sequence-expressions │ ├── assignment-good │ │ ├── actual.js │ │ └── expected.js │ ├── explicit-arrow-root-good │ │ ├── actual.js │ │ └── expected.js │ ├── implicit-arrow-root-good │ │ ├── actual.js │ │ └── expected.js │ ├── root-bad │ │ ├── actual.js │ │ └── expected.js │ └── root-good │ │ ├── actual.js │ │ └── expected.js ├── sibling-root-elements │ ├── hoisted-nested-function │ │ ├── actual.js │ │ └── expected.js │ ├── if-statement │ │ ├── actual.js │ │ └── expected.js │ ├── nested-function │ │ ├── actual.js │ │ └── expected.js │ ├── nested-loop-function │ │ ├── actual.js │ │ └── expected.js │ └── normal │ │ ├── actual.js │ │ └── expected.js ├── skip │ ├── custom │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── default │ │ ├── actual.js │ │ └── expected.js │ └── self-closing │ │ ├── actual.js │ │ └── expected.js ├── spread-attributes │ ├── call │ │ ├── actual.js │ │ └── expected.js │ ├── combined-attributes │ │ ├── actual.js │ │ └── expected.js │ ├── self-closing │ │ ├── actual.js │ │ └── expected.js │ └── variable │ │ ├── actual.js │ │ └── expected.js ├── statics-hoist │ ├── 0 │ │ ├── actual.js │ │ └── expected.js │ ├── 1 │ │ ├── actual.js │ │ └── expected.js │ ├── 2 │ │ ├── actual.js │ │ └── expected.js │ ├── 3 │ │ ├── actual.js │ │ └── expected.js │ ├── 4 │ │ ├── actual.js │ │ └── expected.js │ ├── 5 │ │ ├── actual.js │ │ └── expected.js │ ├── 6 │ │ ├── actual.js │ │ └── expected.js │ ├── 7 │ │ ├── actual.js │ │ └── expected.js │ ├── 8 │ │ ├── actual.js │ │ └── expected.js │ ├── 9 │ │ ├── actual.js │ │ └── expected.js │ ├── 10 │ │ ├── actual.js │ │ └── expected.js │ ├── 11 │ │ ├── actual.js │ │ └── expected.js │ ├── 12 │ │ ├── actual.js │ │ └── expected.js │ ├── 13 │ │ ├── actual.js │ │ └── expected.js │ ├── 14 │ │ ├── actual.js │ │ └── expected.js │ ├── 15 │ │ ├── actual.js │ │ └── expected.js │ ├── 16 │ │ ├── actual.js │ │ └── expected.js │ ├── 17 │ │ ├── actual.js │ │ └── expected.js │ ├── 18 │ │ ├── actual.js │ │ └── expected.js │ ├── 19 │ │ ├── actual.js │ │ └── expected.js │ ├── 20 │ │ ├── actual.js │ │ └── expected.js │ ├── 21 │ │ ├── actual.js │ │ └── expected.js │ ├── 22 │ │ ├── actual.js │ │ └── expected.js │ ├── 23 │ │ ├── actual.js │ │ └── expected.js │ ├── 24 │ │ ├── actual.js │ │ └── expected.js │ ├── 25 │ │ ├── actual.js │ │ └── expected.js │ ├── 26 │ │ ├── actual.js │ │ └── expected.js │ ├── 27 │ │ ├── actual.js │ │ └── expected.js │ ├── 28 │ │ ├── actual.js │ │ └── expected.js │ ├── 29 │ │ ├── actual.js │ │ └── expected.js │ ├── 30 │ │ ├── actual.js │ │ └── expected.js │ ├── key-expression │ │ ├── actual.js │ │ ├── expected.js │ │ └── options.json │ ├── keyless-statics │ │ ├── actual.js │ │ └── expected.js │ └── member-tag-name │ │ ├── actual.js │ │ └── expected.js ├── text │ ├── child-number-literal │ │ ├── actual.js │ │ └── expected.js │ ├── child-string-element-array │ │ ├── actual.js │ │ └── expected.js │ ├── child-string-literal │ │ ├── actual.js │ │ └── expected.js │ ├── child-template-literal │ │ ├── actual.js │ │ └── expected.js │ ├── child │ │ ├── actual.js │ │ └── expected.js │ ├── nested-child │ │ ├── actual.js │ │ └── expected.js │ └── pre │ │ ├── actual.js │ │ └── expected.js └── uuid-prefix │ ├── actual.js │ ├── expected.js │ └── options.json └── index.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"] 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | insert_final_newline = true 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | end_of_line = lf 8 | 9 | [*.{js,json}] 10 | indent_style = space 11 | indent_size = 2 12 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": "eslint:recommended", 4 | "rules": { 5 | "quotes": [2, "double", "avoid-escape"], 6 | "no-var": 2, 7 | "keyword-spacing": 2, 8 | "strict": 0, 9 | "no-underscore-dangle": 0, 10 | "curly": 0, 11 | "no-multi-spaces": 0, 12 | "key-spacing": 0, 13 | "no-return-assign": 0, 14 | "consistent-return": 0, 15 | "no-shadow": 0, 16 | "comma-dangle": 0, 17 | "no-use-before-define": 0, 18 | "no-empty": 0, 19 | "new-parens": 0, 20 | "no-cond-assign": 0, 21 | "no-fallthrough": 0, 22 | "new-cap": 0, 23 | "no-loop-func": 0, 24 | "no-unreachable": 0, 25 | "no-labels": 0, 26 | "no-process-exit": 0, 27 | "camelcase": 0, 28 | "no-console": 0, 29 | "no-constant-condition": 0, 30 | "no-inner-declarations": 0 31 | }, 32 | "env": { 33 | "node": true, 34 | "es6": true 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | lib 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | src 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "8" 4 | - "stable" 5 | sudo: false 6 | script: npm test && npm run lint 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 James Kyle and Justin Ridgewell 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-plugin-transform-incremental-dom", 3 | "version": "5.0.0", 4 | "description": "Turn jsx into incremental-dom", 5 | "repository": "jridgewell/babel-plugin-transform-incremental-dom", 6 | "license": "MIT", 7 | "main": "lib/index.js", 8 | "dependencies": { 9 | "@babel/plugin-syntax-jsx": "7.2.0", 10 | "@babel/types": "7.2.0" 11 | }, 12 | "devDependencies": { 13 | "@babel/cli": "7.6.2", 14 | "@babel/core": "7.6.2", 15 | "@babel/plugin-transform-modules-commonjs": "7.6.0", 16 | "@babel/preset-env": "7.6.2", 17 | "@babel/register": "7.6.2", 18 | "babel-eslint": "10.0.3", 19 | "eslint": "6.5.1", 20 | "mocha": "6.2.1" 21 | }, 22 | "scripts": { 23 | "preversion": "npm test && npm run lint", 24 | "version": "npm run build", 25 | "build": "babel src --out-dir lib --copy-files", 26 | "test": "mocha --require @babel/register", 27 | "lint": "eslint src" 28 | }, 29 | "keywords": [ 30 | "babel-plugin", 31 | "transform", 32 | "incremental-dom", 33 | "jsx" 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /src/helpers/add-import.js: -------------------------------------------------------------------------------- 1 | import * as t from "@babel/types"; 2 | 3 | const importMap = new WeakMap(); 4 | 5 | export default function addImport(file, source, imported) { 6 | let imports = importMap.get(file); 7 | if (!imports) { 8 | imports = {}; 9 | importMap.set(file, imports); 10 | } 11 | 12 | const alias = `${source}:${imported}`; 13 | if (imports[alias]) { 14 | return t.cloneNode(imports[alias]); 15 | } 16 | 17 | const { scope } = file; 18 | const id = scope.generateUidIdentifier(imported); 19 | imports[alias] = id; 20 | 21 | const specifier = t.importSpecifier(id, t.identifier(imported)); 22 | const declaration = t.importDeclaration([specifier], t.stringLiteral(source)); 23 | file.path.unshiftContainer("body", declaration); 24 | 25 | return t.cloneNode(id); 26 | } 27 | -------------------------------------------------------------------------------- /src/helpers/ast/flatten-expressions.js: -------------------------------------------------------------------------------- 1 | import toStatement from "./to-statement"; 2 | import * as t from "@babel/types"; 3 | 4 | // Helper to flatten out sequence expressions into a top level 5 | // expression statements. 6 | export default function flattenExpressions(expressions, nodes = []) { 7 | return expressions.reduce((nodes, node) => { 8 | if (t.isSequenceExpression(node)) { 9 | return flattenExpressions(node.expressions, nodes); 10 | } 11 | 12 | nodes.push(toStatement(node)); 13 | return nodes; 14 | }, nodes); 15 | } 16 | -------------------------------------------------------------------------------- /src/helpers/ast/statements-with-return-last.js: -------------------------------------------------------------------------------- 1 | import * as t from "@babel/types"; 2 | 3 | // Ensures the final statement is a return statement. 4 | export default function statementsWithReturnLast(statements) { 5 | const lastIndex = statements.length - 1; 6 | const last = statements[lastIndex]; 7 | 8 | if (!t.isReturnStatement(last)) { 9 | statements[lastIndex] = t.returnStatement(last.expression); 10 | } 11 | 12 | return statements; 13 | } 14 | -------------------------------------------------------------------------------- /src/helpers/ast/to-function-call.js: -------------------------------------------------------------------------------- 1 | import toReference from "./to-reference"; 2 | import * as t from "@babel/types"; 3 | 4 | // Helper to create a function call in AST. 5 | export default function toFunctionCall(functionName, args) { 6 | return t.callExpression(toReference(functionName), args); 7 | } 8 | -------------------------------------------------------------------------------- /src/helpers/ast/to-reference.js: -------------------------------------------------------------------------------- 1 | import * as t from "@babel/types"; 2 | 3 | // Helper to transform a JSX identifier into a normal reference. 4 | export default function toReference(node, identifier = false) { 5 | if (typeof node === "string") { 6 | return node. 7 | split("."). 8 | map((s) => t.identifier(s)). 9 | reduce((obj, prop) => t.memberExpression(obj, prop)); 10 | } 11 | 12 | if (t.isJSXIdentifier(node)) { 13 | return identifier ? t.identifier(node.name) : t.stringLiteral(node.name); 14 | } 15 | 16 | if (t.isJSXMemberExpression(node)) { 17 | return t.memberExpression( 18 | toReference(node.object, true), 19 | toReference(node.property, true) 20 | ); 21 | } 22 | 23 | return node; 24 | } 25 | -------------------------------------------------------------------------------- /src/helpers/ast/to-statement.js: -------------------------------------------------------------------------------- 1 | import * as t from "@babel/types"; 2 | 3 | // Helper to transform an expression into an expression statement. 4 | export default function toStatement(expression) { 5 | if (t.isFunctionExpression(expression)) { 6 | return t.toStatement(expression); 7 | } 8 | if (!t.isStatement(expression)) { 9 | return t.expressionStatement(expression); 10 | } 11 | return expression; 12 | } 13 | -------------------------------------------------------------------------------- /src/helpers/ast/to-string.js: -------------------------------------------------------------------------------- 1 | import * as t from "@babel/types"; 2 | 3 | // Helper to transform a literal into an string literal. 4 | export default function toString(literal, restricted = false) { 5 | let string; 6 | if (literal.isStringLiteral() || literal.isTemplateLiteral()) { 7 | return literal.node; 8 | } 9 | 10 | if (literal.isIdentifier()) { 11 | string = literal.node.name; 12 | } else if (literal.isUnaryExpression({ operator: "void" })) { 13 | string = "undefined"; 14 | } else if (literal.isNullLiteral()) { 15 | string = "null"; 16 | } else if (literal.isNumericLiteral() || literal.isBooleanLiteral()) { 17 | string = String(literal.node.value); 18 | } 19 | 20 | if (restricted && (string === "undefined" || string === "null" || string === "true" || string === "false")) { 21 | return; 22 | } 23 | 24 | return t.stringLiteral(string); 25 | } 26 | -------------------------------------------------------------------------------- /src/helpers/attributes.js: -------------------------------------------------------------------------------- 1 | import injectSpreadAttribute from "./runtime/spread-attribute"; 2 | import toFunctionCall from "./ast/to-function-call"; 3 | import iDOMMethod from "./idom-method"; 4 | 5 | // Detects if one of the attributes is a JSX Spread Attribute 6 | export function hasSpread(attributes) { 7 | return attributes.some((attr) => attr.isJSXSpreadAttribute()); 8 | } 9 | 10 | // Detects if the skip attribute is used 11 | export function hasSkip(attributes, { opts }) { 12 | const skipAttribute = opts.skipAttribute || "__skip"; 13 | return attributes.some((attr) => attr.isJSXAttribute() && attr.node.name.name === skipAttribute); 14 | } 15 | 16 | // Returns an array of `name`-`value` attribute pairs 17 | export function toAttrsArray(attrs) { 18 | const pairsArray = []; 19 | attrs.forEach(({ name, value }) => { 20 | pairsArray.push(name) 21 | pairsArray.push(value); 22 | }); 23 | 24 | return pairsArray; 25 | } 26 | 27 | // Returns an array of iDOM `attr` calls 28 | export function toAttrsCalls(attrs, plugin) { 29 | const attr = iDOMMethod("attr", plugin); 30 | const spreadAttr = injectSpreadAttribute(plugin); 31 | 32 | return attrs.map(({ name, value, isSpread }) => { 33 | if (isSpread) { 34 | return toFunctionCall(spreadAttr, [value]); 35 | } 36 | 37 | return toFunctionCall(attr, [ name, value ]); 38 | }); 39 | } 40 | -------------------------------------------------------------------------------- /src/helpers/clean-text.js: -------------------------------------------------------------------------------- 1 | import * as t from "@babel/types"; 2 | 3 | const nonWhitespace = /\S/; 4 | const whitespace = /\s+/g; 5 | 6 | // Cleans the whitespace from a text node. 7 | export default function cleanText(jsxText) { 8 | const text = jsxText.node.value; 9 | if (!nonWhitespace.test(text)) { 10 | return ""; 11 | } 12 | 13 | return t.stringLiteral(text.replace(whitespace, " ")); 14 | } 15 | -------------------------------------------------------------------------------- /src/helpers/collect-imports.js: -------------------------------------------------------------------------------- 1 | import * as t from "@babel/types"; 2 | 3 | const importDeclarationFinder = { 4 | ImportDeclaration(path) { 5 | const {specifiers, source} = path.node; 6 | const src = source.value; 7 | 8 | let imports = this.imports.find((imports) => imports.source === src); 9 | if (!imports) { 10 | imports = { 11 | source: src, 12 | imported: [], 13 | specifiers: [], 14 | }; 15 | this.imports.push(imports); 16 | } 17 | 18 | for (let i = 0; i < specifiers.length; i++) { 19 | const specifier = specifiers[i]; 20 | const local = specifier.local.name; 21 | if (t.isImportDefaultSpecifier(specifier)) { 22 | imports.imported.push("default"); 23 | imports.specifiers.push({ kind: "named", imported: "default", local }); 24 | } else if (t.isImportNamespaceSpecifier(specifier)) { 25 | imports.imported.push("*"); 26 | imports.specifiers.push({ kind: "namespace", local }); 27 | } else { 28 | const imported = specifier.imported.name; 29 | imports.imported.push(imported); 30 | imports.specifiers.push({ kind: "named", imported, local }); 31 | } 32 | } 33 | }, 34 | 35 | ExpressionStatement(path) { 36 | path.skip(); 37 | }, 38 | }; 39 | 40 | // Gathers the import statements in this file. 41 | export default function collectImports(program) { 42 | const imports = []; 43 | program.traverse(importDeclarationFinder, { imports }) 44 | 45 | return imports; 46 | } 47 | -------------------------------------------------------------------------------- /src/helpers/completion-records.js: -------------------------------------------------------------------------------- 1 | import useFastRoot, { fastRootAncestor } from "./fast-root"; 2 | import last from "./last"; 3 | 4 | const map = new WeakMap(); 5 | 6 | export function getCompletionRecords(path, find = null) { 7 | const stack = [path]; 8 | let i = 0; 9 | while (i < stack.length) { 10 | const p = stack[i]; 11 | if (p.isSequenceExpression()) { 12 | stack[i] = last(p.get("expressions")); 13 | } else if (p.isConditionalExpression()) { 14 | stack[i] = p.get("consequent"); 15 | stack.push(p.get("alternate")); 16 | } else if (p.isLogicalExpression()) { 17 | if (!find || p.node.operator === "||") { 18 | stack.push(p.get("left")); 19 | } 20 | stack[i] = p.get("right"); 21 | } else if (find && p === find) { 22 | return true; 23 | } else { 24 | i++; 25 | } 26 | } 27 | 28 | return find ? false : stack; 29 | } 30 | 31 | // Determines if the element is a completion record. 32 | export function isCompletionRecord(path, { fastRoots, opts }) { 33 | let is; 34 | 35 | if (useFastRoot(path, opts) && fastRootAncestor(path, fastRoots)) { 36 | is = true; 37 | } else { 38 | const container = path.findParent(p => p.isJSX()); 39 | 40 | if (!container || container.isJSXElement()) { 41 | is = true; 42 | } else if (container.isJSXAttribute() || container.parentPath.isJSXAttribute()) { 43 | is = false; 44 | } else { 45 | is = getCompletionRecords(container.get("expression"), path); 46 | } 47 | } 48 | 49 | map.set(path, is); 50 | return is; 51 | } 52 | -------------------------------------------------------------------------------- /src/helpers/element-close-call.js: -------------------------------------------------------------------------------- 1 | import toFunctionCall from "./ast/to-function-call"; 2 | import toReference from "./ast/to-reference"; 3 | 4 | import iDOMMethod from "./idom-method"; 5 | import isComponent from "./is-component"; 6 | import { hasSpread, hasSkip } from "./attributes"; 7 | 8 | // Returns the closing element's function call. 9 | export default function elementCloseCall(path, plugin) { 10 | const { node } = path; 11 | 12 | const attributes = path.get("attributes"); 13 | // Self closing elements that do not contain a SpreadAttribute will use `elementVoid`, 14 | // so the closing `elementClose` is not needed. 15 | if (node.selfClosing && !hasSpread(attributes) && !hasSkip(attributes, plugin)) { 16 | return null; 17 | } 18 | 19 | const name = path.get("name"); 20 | const useReference = isComponent(name, plugin); 21 | return toFunctionCall(iDOMMethod("elementClose", plugin), [toReference(name.node, useReference)]); 22 | } 23 | -------------------------------------------------------------------------------- /src/helpers/idom-method.js: -------------------------------------------------------------------------------- 1 | import toReference from "./ast/to-reference"; 2 | import moduleSource from "./module-source"; 3 | import addImport from "./add-import"; 4 | 5 | // Returns a reference to an iDOM method. 6 | export default function iDOMMethod(method, plugin) { 7 | const importSource = moduleSource(plugin); 8 | 9 | if (importSource) { 10 | return addImport(plugin.file, importSource, method); 11 | } 12 | 13 | return toReference(method); 14 | } 15 | -------------------------------------------------------------------------------- /src/helpers/inline-expressions.js: -------------------------------------------------------------------------------- 1 | import expressionExtractor from "./extract-expressions"; 2 | import * as t from "@babel/types"; 3 | 4 | // Take single use variable declarations and move them inside 5 | // the JSX Expression Container where they are referenced. 6 | const expressionInliner = { 7 | JSXExpressionContainer(path) { 8 | const expression = path.get("expression"); 9 | if (!expression.isIdentifier()) { 10 | return; 11 | } 12 | 13 | const binding = path.scope.getBinding(expression.node.name); 14 | if (!binding || binding.references > 1 || !binding.constant) { 15 | return; 16 | } 17 | 18 | const declarator = binding.path; 19 | if (!declarator.isVariableDeclarator()) { 20 | return; 21 | } 22 | 23 | const init = declarator.get("init"); 24 | if (!init.isJSXElement()) { 25 | return; 26 | } 27 | 28 | const closureVars = []; 29 | const state = Object.assign({}, this, { 30 | closureVarsStack: [closureVars] 31 | }); 32 | init.traverse(expressionExtractor, state); 33 | 34 | expression.replaceWith(init.node); 35 | declarator.replaceWithMultiple(closureVars.map((cv) => { 36 | return t.variableDeclarator(cv.id, cv.init); 37 | })); 38 | } 39 | }; 40 | 41 | export default expressionInliner; 42 | -------------------------------------------------------------------------------- /src/helpers/is-component.js: -------------------------------------------------------------------------------- 1 | const componentTester = /^[A-Z]/; 2 | 3 | // Detects if the given tag represents a component (that is, if it starts with a 4 | // capital letter). 5 | export default function isComponent(path, { opts }) { 6 | if (!opts.components || !path.isJSXIdentifier()) { 7 | return false; 8 | } 9 | 10 | return componentTester.test(path.node.name); 11 | } 12 | -------------------------------------------------------------------------------- /src/helpers/is-literal-or-special.js: -------------------------------------------------------------------------------- 1 | import * as t from "@babel/types"; 2 | 3 | // Literals and `undefined` are treated as constant values in attributes and 4 | // children. 5 | export default function isLiteralOrSpecial(path) { 6 | return isLiteralOrSpecialNode(path.node); 7 | } 8 | 9 | export function isLiteralOrSpecialNode(node) { 10 | if (t.isTemplateLiteral(node)) { 11 | return node.expressions.every(isLiteralOrSpecialNode); 12 | } 13 | return t.isLiteral(node) || 14 | t.isUnaryExpression(node, { operator: "void" }) || 15 | t.isIdentifier(node, { name: "undefined" }) || 16 | t.isIdentifier(node, { name: "NaN" }) || 17 | t.isIdentifier(node, { name: "Infinity" }); 18 | } 19 | -------------------------------------------------------------------------------- /src/helpers/is-returned.js: -------------------------------------------------------------------------------- 1 | // This node is returned if it's parent is explicitly or 2 | // implicitly returned. 3 | export default function isReturned(path) { 4 | const parent = path.parentPath; 5 | return parent.isReturnStatement() || parent.isArrowFunctionExpression(); 6 | } 7 | -------------------------------------------------------------------------------- /src/helpers/last.js: -------------------------------------------------------------------------------- 1 | // Grab the last element of an array. 2 | export default function last(array) { 3 | return array[array.length - 1]; 4 | } 5 | 6 | -------------------------------------------------------------------------------- /src/helpers/module-source.js: -------------------------------------------------------------------------------- 1 | import collectImports from "./collect-imports"; 2 | import resolvePath from "./resolve-path"; 3 | 4 | // Determines the import module source for iDOM. 5 | export default function moduleSource({ opts, file }) { 6 | let { moduleSource } = opts; 7 | if (moduleSource) { 8 | return resolvePath(file.opts.filename, moduleSource); 9 | } 10 | 11 | // See if we can find the incremental-dom import. 12 | const imports = collectImports(file.path); 13 | const imported = imports.find((imported) => { 14 | return imported.source === "incremental-dom"; 15 | }); 16 | 17 | if (imported) { 18 | return "incremental-dom"; 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /src/helpers/resolve-path.js: -------------------------------------------------------------------------------- 1 | import { dirname, join, relative } from "path"; 2 | 3 | export default function resolvePath(currentFile, path) { 4 | if (path.startsWith(".")) { 5 | path = relative( 6 | dirname(currentFile), 7 | join(process.cwd(), path) 8 | ); 9 | } 10 | 11 | return path; 12 | } 13 | -------------------------------------------------------------------------------- /src/helpers/runtime/has-own.js: -------------------------------------------------------------------------------- 1 | import inject from "../inject"; 2 | import * as t from "@babel/types"; 3 | 4 | // Caches a reference to Object#hasOwnProperty. 5 | function hasOwnAST() { 6 | /** 7 | * var _hasOwn = Object.prototype.hasOwnProperty; 8 | */ 9 | return t.memberExpression( 10 | t.memberExpression( 11 | t.identifier("Object"), 12 | t.identifier("prototype") 13 | ), 14 | t.identifier("hasOwnProperty") 15 | ); 16 | } 17 | 18 | export default function injectHasOwn(plugin) { 19 | return inject(plugin, "hasOwn", hasOwnAST); 20 | } 21 | -------------------------------------------------------------------------------- /src/helpers/runtime/jsx-wrapper.js: -------------------------------------------------------------------------------- 1 | import inject from "../inject"; 2 | import * as t from "@babel/types"; 3 | 4 | // Wraps a JSX element in a lazy evaluation struct, capturing the arguments 5 | // that its attributes and children need to render. 6 | // We identify the struct by the __jsxDOMWrapper property. 7 | function jsxWrapperAST(plugin, ref) { 8 | const func = t.identifier("func"); 9 | const args = t.identifier("args"); 10 | 11 | /** 12 | * function _jsxWrapper(func, args) { 13 | * return { 14 | * __jsxDOMWrapper: true, 15 | * func: func, 16 | * args: args, 17 | * }; 18 | * } 19 | */ 20 | return t.functionExpression( 21 | ref, 22 | [func, args], 23 | t.blockStatement([ 24 | t.returnStatement(t.objectExpression([ 25 | t.objectProperty(t.identifier("__jsxDOMWrapper"), t.booleanLiteral(true)), 26 | t.objectProperty(func, func), 27 | t.objectProperty(args, args) 28 | ])) 29 | ]) 30 | ); 31 | } 32 | 33 | export default function injectJSXWrapper(plugin) { 34 | return inject(plugin, "jsxWrapper", jsxWrapperAST); 35 | } 36 | -------------------------------------------------------------------------------- /src/helpers/runtime/spread-attribute.js: -------------------------------------------------------------------------------- 1 | import inject from "../inject"; 2 | import injectHasOwn from "./has-own"; 3 | import toFunctionCall from "../ast/to-function-call"; 4 | import iDOMMethod from "../idom-method"; 5 | import * as t from "@babel/types"; 6 | 7 | // Iterates over a SpreadAttribute, assigning each property as an attribute 8 | // on the element. 9 | function spreadAttributeAST(plugin, ref, deps) { 10 | const { hasOwn } = deps; 11 | const spread = t.identifier("spread"); 12 | const prop = t.identifier("prop"); 13 | 14 | /** 15 | * function _spreadAttribute(spread) { 16 | * for (var prop in spread) { 17 | * if (_hasOwn.call(spread, prop)) { 18 | * attr(prop, spread[prop]); 19 | * } 20 | * } 21 | * } 22 | */ 23 | return t.functionExpression( 24 | ref, 25 | [spread], 26 | t.blockStatement([ 27 | t.forInStatement( 28 | t.variableDeclaration("var", [t.variableDeclarator(prop)]), 29 | spread, 30 | t.ifStatement( 31 | toFunctionCall(t.memberExpression( 32 | hasOwn, 33 | t.identifier("call") 34 | ), [spread, prop]), 35 | t.expressionStatement(toFunctionCall(iDOMMethod("attr", plugin), [ 36 | prop, 37 | t.memberExpression(spread, prop, true) 38 | ])) 39 | ) 40 | ) 41 | ]) 42 | ); 43 | } 44 | 45 | export default function injectSpreadAttribute(plugin) { 46 | return inject(plugin, "spreadAttribute", spreadAttributeAST, { 47 | hasOwn: injectHasOwn 48 | }); 49 | } 50 | -------------------------------------------------------------------------------- /src/helpers/uuid.js: -------------------------------------------------------------------------------- 1 | import { randomBytes } from "crypto"; 2 | 3 | let i = 1; 4 | 5 | // @jed's brilliantly short UUID v4 generator 6 | // https://gist.github.com/jed/982883 7 | export default function uuid({ opts }) { 8 | const { uuidPrefix } = opts; 9 | if (uuidPrefix) { 10 | return uuidPrefix + i++; 11 | } 12 | 13 | return "00000000-0000-4000-8000-000000000000".replace(/[08]/g, randomizer); 14 | } 15 | 16 | function randomizer(bit) { 17 | return (bit ^ randomBytes(1)[0] % 16 >> bit / 4).toString(16); 18 | } 19 | -------------------------------------------------------------------------------- /src/messages.js: -------------------------------------------------------------------------------- 1 | export const prefixOptionRemoved = 2 | `babel-plugin-transform-incremental-dom: 3 | Using removed 'prefix' plugin option. 4 | Please use the new 'moduleSource'. 5 | https://github.com/jridgewell/babel-plugin-transform-incremental-dom#auto-importing-incremental-dom`; 6 | 7 | export const runtimeOptionRemoved = 8 | `babel-plugin-transform-incremental-dom: 9 | Using removed 'runtime' plugin option. 10 | Please use the new 'runtimeModuleSource'. 11 | (Please note that \`spreadAttribute\` has been added to runtime!) 12 | https://github.com/jridgewell/babel-plugin-transform-incremental-dom#runtime`; 13 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
{}
; 3 | } 4 | 5 | function render() { 6 | return
{{children: [1, 2, 3]}}
; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/arrow-return/explicit/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return items.map((item) => { 3 | return
; 4 | }); 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/arrow-return/explicit/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return items.map(function (item) { 3 | elementOpen("div"); 4 | return elementClose("div"); 5 | }); 6 | } -------------------------------------------------------------------------------- /test/fixtures/arrow-return/implicit/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return items.map((item) =>
); 3 | } -------------------------------------------------------------------------------- /test/fixtures/arrow-return/implicit/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return items.map(function (item) { 3 | elementOpen("div"); 4 | return elementClose("div"); 5 | }); 6 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-expression/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
: }>
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-expression/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _span$wrapper = function _span$wrapper() { 10 | return elementVoid("span"); 11 | }, 12 | _span$wrapper2 = function _span$wrapper2() { 13 | return elementVoid("span"); 14 | }; 15 | 16 | function render() { 17 | elementOpen("root"); 18 | elementOpen("div", null, null, "prop", x ? _jsxWrapper(_span$wrapper) : _jsxWrapper(_span$wrapper2)); 19 | elementClose("div"); 20 | return elementClose("root"); 21 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-false/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-false/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "false"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "__uuid__0__", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-infinity/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-infinity/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "Infinity"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "__uuid__0__", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-nan/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-nan/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "NaN"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "__uuid__0__", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-null/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-null/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "null"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "__uuid__0__", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-number/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-number/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "0"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "__uuid__0__", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-prop/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-prop/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("root"); 3 | elementOpen("div", null, null, "class", props.myClass); 4 | elementClose("div"); 5 | return elementClose("root"); 6 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-string/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-string/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "my-class"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "__uuid__0__", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-true/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-true/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "true"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "__uuid__0__", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-undefined/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-undefined/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "undefined"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "__uuid__0__", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-void/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed-void/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "undefined"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "__uuid__0__", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/computed/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/computed/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("root"); 3 | elementOpen("div", null, null, "class", myClass); 4 | elementClose("div"); 5 | return elementClose("root"); 6 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/element-in-attribute/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/attributes/element-in-attribute/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$wrapper = function _div$wrapper() { 10 | return elementVoid("div"); 11 | }; 12 | 13 | function render() { 14 | elementOpen("ul", null, null, "files", _jsxWrapper(_div$wrapper)); 15 | return elementClose("ul"); 16 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/implicit-true/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | 4 |
; 5 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/implicit-true/expected.js: -------------------------------------------------------------------------------- 1 | var _input$statics = ["disabled", "true"]; 2 | 3 | function render() { 4 | elementOpen("div"); 5 | elementVoid("input", "__uuid__0__", _input$statics); 6 | return elementClose("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/jsx-element-computed-attr/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
}>
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/jsx-element-computed-attr/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _span$wrapper = function _span$wrapper(_attr) { 10 | return elementVoid("span", null, null, "attr", _attr); 11 | }; 12 | 13 | function render() { 14 | elementOpen("root"); 15 | elementOpen("div", null, null, "prop", _jsxWrapper(_span$wrapper, [i++])); 16 | elementClose("div"); 17 | return elementClose("root"); 18 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/jsx-element-computed-child/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
{i++}}>
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/literal-require-statics-key/actual.js: -------------------------------------------------------------------------------- 1 | function render(condition) { 2 | return 3 | {condition 4 | ?
5 | :
6 | } 7 |
; 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures/attributes/literal-require-statics-key/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render(condition) { 33 | elementOpen("root"); 34 | 35 | _renderArbitrary(condition ? (elementOpen("div", null, null, "class", "my-class", "attr", i++), elementClose("div")) : (elementOpen("div", null, null, "attr", i++, "class", "other-class"), elementClose("div"))); 36 | 37 | return elementClose("root"); 38 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/literal-require-statics-key/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "requireStaticsKey": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/literal-with-key/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/literal-with-key/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "my-class", "key", "key"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "key", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/attributes/literal/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["class", "my-class"]; 2 | 3 | function render() { 4 | elementOpen("root"); 5 | elementOpen("div", "__uuid__0__", _div$statics); 6 | elementClose("div"); 7 | return elementClose("root"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/attributes/nested-element-in-attribute/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return ; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/attributes/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | function fn() {} 3 | var div =
; 4 | return {div}; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/call/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | function fn() {} 3 | var div =
{fn()}
; 4 | return {div}; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/conditional/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | function fn() {} 3 | function fn2() {} 4 | function fn3() {} 5 | var div =
6 | {true ? fn2() : 'a'} 7 | {true ? fn2() : fn3()} 8 | {fn() ? fn2() : fn3()} 9 | {1, 2, true ? fn2() : fn3()} 10 | {true && (true ? fn2() : fn3())} 11 | {true || (true ? fn2() : fn3())} 12 |
; 13 | return {div}; 14 | } 15 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/inner-call/actual.js: -------------------------------------------------------------------------------- 1 | function renderMessage(i) { 2 | return {"my message " + i}; 3 | } 4 | 5 | function render() { 6 | var ul = ; 13 | return {ul}; 14 | } 15 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/logical/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | function fn() {} 3 | var div =
4 | {true && fn()} 5 | {true || fn()} 6 | {fn() || true} 7 | {fn() && true} 8 | {1, 2, true && fn()} 9 | {1, 2, true || fn()} 10 | {true ? true && fn() : true && fn()} 11 | {true ? true || fn() : true || fn()} 12 |
; 13 | return {div}; 14 | } 15 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/member-call/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var a = { b: { fn() { } } }; 3 | var div =
{a.b.fn()}
; 4 | return {div}; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/mutated-params/call/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div =
3 | {fn(i++)} 4 |
; 5 | return {div}; 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/mutated-params/conditional/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div =
3 | {true ? fn(a++) : fn2(b++, c++)} 4 | {fn(i++) ? fn(a++) : fn2(b++, c++)} 5 |
; 6 | return {div}; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/mutated-params/logical/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div =
3 | {true && fn(i++)} 4 | {true || fn(i++)} 5 |
; 6 | return {div}; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/mutated-params/member-call/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div =
3 | {a.b.fn(i++)} 4 |
; 5 | return {div}; 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/mutated-params/sequence/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div =
3 | {1, 2, fn(i++)} 4 |
; 5 | return {div}; 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/optimizations/literal-args/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | function fn() {} 3 | var div =
4 | {fn(1, true, i, 'test')} 5 | {fn(1, a, 2, i, 'test')} 6 |
; 7 | return {div}; 8 | } 9 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/optimizations/single-arg/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | function fn() {} 3 | var div =
4 | {fn(args)} 5 | {true ? fn(args) : fn2()} 6 | {true ? fn() : fn2(args)} 7 |
; 8 | return {div}; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/sequence/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | function fn() {} 3 | function fn2() {} 4 | var div =
5 | {1, 2, fn2()} 6 | {1, fn(), fn2()} 7 | {true ? (1, 2, fn2()) : (1, 2, fn2())} 8 | {true && (1, fn(), fn2())} 9 | {true || (1, fn(), fn2())} 10 |
; 11 | return {div}; 12 | } 13 | -------------------------------------------------------------------------------- /test/fixtures/call-expression-defer/wrapper/spread/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | function fn() {} 3 | var div =
4 | {fn(...args)} 5 | {fn(1, ...args)} 6 | {fn.test(...args)} 7 |
; 8 | return {div}; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/comment/child/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {/* child */} 4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/comment/child/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | return elementClose("div"); 4 | } -------------------------------------------------------------------------------- /test/fixtures/comment/inline/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
; 3 | } -------------------------------------------------------------------------------- /test/fixtures/comment/inline/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return elementVoid("div"); 3 | } -------------------------------------------------------------------------------- /test/fixtures/components/component/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/components/component/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen(MyComponent); 3 | return elementClose(MyComponent); 4 | } -------------------------------------------------------------------------------- /test/fixtures/components/component/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "components": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/components/element/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/components/element/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | return elementClose("div"); 4 | } -------------------------------------------------------------------------------- /test/fixtures/components/element/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "components": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/components/member-expression-tag/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/components/member-expression-tag/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen(a.b.MyComponent); 3 | return elementClose(a.b.MyComponent); 4 | } -------------------------------------------------------------------------------- /test/fixtures/components/member-expression-tag/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "components": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/eager-expressions/non-root/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var test =
3 |
4 | {i++} 5 |
6 | {i++} 7 |
8 | {i++} 9 |
10 |
11 | return {test}; 12 | } 13 | -------------------------------------------------------------------------------- /test/fixtures/eager-expressions/root-nested-function/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 | {[1, 2, 3].map(function(i) { 5 | return {i}; 6 | })} 7 | {function() { 8 |
9 | {i++} 10 |
11 | }()} 12 | {i++} 13 |
14 | {i++} 15 |
16 |
17 |
; 18 | } 19 | -------------------------------------------------------------------------------- /test/fixtures/eager-expressions/root/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 |
4 |
5 | {i++} 6 |
7 | {i++} 8 |
9 | {i++} 10 |
11 |
12 |
; 13 | } 14 | -------------------------------------------------------------------------------- /test/fixtures/element/component-custom-element/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/element/component-custom-element/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("MyComponent"); 3 | return elementClose("MyComponent"); 4 | } -------------------------------------------------------------------------------- /test/fixtures/element/member-expression-tag/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/element/member-expression-tag/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen(a.b.div); 3 | return elementClose(a.b.div); 4 | } -------------------------------------------------------------------------------- /test/fixtures/element/nested/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
; 17 | } 18 | -------------------------------------------------------------------------------- /test/fixtures/element/nested/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | elementOpen("div"); 4 | elementClose("div"); 5 | elementOpen("div"); 6 | elementOpen("div"); 7 | elementClose("div"); 8 | elementOpen("div"); 9 | elementOpen("div"); 10 | elementClose("div"); 11 | elementOpen("div"); 12 | elementOpen("div"); 13 | elementClose("div"); 14 | elementOpen("div"); 15 | elementOpen("div"); 16 | elementClose("div"); 17 | elementClose("div"); 18 | elementClose("div"); 19 | elementClose("div"); 20 | elementClose("div"); 21 | return elementClose("div"); 22 | } -------------------------------------------------------------------------------- /test/fixtures/element/root/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/element/root/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | return elementClose("div"); 4 | } -------------------------------------------------------------------------------- /test/fixtures/error/namespace/attribute/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/error/namespace/attribute/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "throws": "JSX Namespaces aren't supported." 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/error/namespace/element/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/error/namespace/element/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "throws": "JSX Namespaces aren't supported." 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/error/namespace/namespace-attributes-element-namespace/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/error/namespace/namespace-attributes-element-namespace/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "throws": "JSX Namespaces aren't supported.", 3 | "options": { 4 | "namespaceAttributes": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/0/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var children = [1, 2, 3, will be wrapped]; 3 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/0/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _children$wrapper = function _children$wrapper() { 10 | elementOpen("array"); 11 | text("will be wrapped"); 12 | return elementClose("array"); 13 | }; 14 | 15 | function render() { 16 | var children = [1, 2, 3, _jsxWrapper(_children$wrapper)]; 17 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/1/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var items = []; 3 | for (var i = 0; i < 10; i++) { 4 | items.push(
{i}
); 5 | } 6 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/10/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var mapNested = [1, 2, 3].map(function(i) { 3 | return {i}; 4 | }); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/10/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | var mapNested = [1, 2, 3].map(function (i) { 34 | elementOpen("outer"); 35 | elementOpen("inner"); 36 | 37 | _renderArbitrary(i); 38 | 39 | elementClose("inner"); 40 | return elementClose("outer"); 41 | }); 42 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/11/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var mapNested2 = [1, 2, 3].map(function(i) { 3 | return {{i}}; 4 | }); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/11/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | var mapNested2 = [1, 2, 3].map(function (i) { 34 | elementOpen("outer2"); 35 | elementOpen("inner2"); 36 | 37 | _renderArbitrary(i); 38 | 39 | elementClose("inner2"); 40 | return elementClose("outer2"); 41 | }); 42 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/12/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var mapNested3 = [1, 2, 3].map(function(i) { 3 | return ; 4 | }); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/12/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var mapNested3 = [1, 2, 3].map(function (i) { 3 | elementOpen("outer3"); 4 | elementOpen("inner3", null, null, "attr", i); 5 | elementClose("inner3"); 6 | return elementClose("outer3"); 7 | }); 8 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/13/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var mapNested4 = [1, 2, 3].map(function(i) { 3 | return {{i}}>}; 4 | }); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/14/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var mapNested5 = [1, 2, 3].map(function(i) { 3 | return {{i++}{i}}>}; 4 | }); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/15/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 | {children} 4 | {won't be wrapped} 5 |
{one}
{two}
{two}
6 |
; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/2/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var items = []; 3 | for (var i = 0; i < 10; i++) { 4 | items[i] =
{i}
; 5 | } 6 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/3/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var map = [1, 2, 3].map(function(i) { 3 | return {i}; 4 | }); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/3/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | var map = [1, 2, 3].map(function (i) { 34 | elementOpen("map"); 35 | 36 | _renderArbitrary(i); 37 | 38 | return elementClose("map"); 39 | }); 40 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/4/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var map2 = [1, 2, 3].map(function(i) { 3 | var el = {i}; 4 | return el; 5 | }); 6 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/5/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var map3 = function() { 3 | [1, 2, 3].map(function(i) { 4 | return {i}; 5 | }); 6 | } 7 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/5/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | var map3 = function map3() { 34 | [1, 2, 3].map(function (i) { 35 | elementOpen("map3"); 36 | 37 | _renderArbitrary(i); 38 | 39 | return elementClose("map3"); 40 | }); 41 | }; 42 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/6/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var attr = 0; 3 | var attrs = [1, 2, 3].map(function() { 4 | return {attr++}; 5 | }); 6 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/6/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | var attr = 0; 34 | var attrs = [1, 2, 3].map(function () { 35 | elementOpen("attrs", null, null, "attr", attr++); 36 | 37 | _renderArbitrary(attr++); 38 | 39 | return elementClose("attrs"); 40 | }); 41 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/7/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var declarator =
will be wrapped
; 3 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/7/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _declarator$wrapper = function _declarator$wrapper() { 10 | elementOpen("div"); 11 | text("will be wrapped"); 12 | return elementClose("div"); 13 | }; 14 | 15 | function render() { 16 | var declarator = _jsxWrapper(_declarator$wrapper); 17 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/8/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var assignment; 3 | assignment =
will be wrapped
; 4 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/8/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _assignment$wrapper = function _assignment$wrapper() { 10 | elementOpen("div"); 11 | text("will be wrapped"); 12 | return elementClose("div"); 13 | }; 14 | 15 | function render() { 16 | var assignment; 17 | assignment = _jsxWrapper(_assignment$wrapper); 18 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/9/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var i = 1; 3 | var one = {i++}; 4 | var two = {i++}; 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/0/actual.js: -------------------------------------------------------------------------------- 1 | function check(count) { 2 | return count > 5; 3 | } 4 | 5 | function render(data) { 6 | return 7 | {true && check(data.count) && } 8 | ; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/0/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function check(count) { 33 | return count > 5; 34 | } 35 | 36 | function render(data) { 37 | elementOpen("root"); 38 | 39 | _renderArbitrary(true && check(data.count) && elementVoid("WowSoMany")); 40 | 41 | return elementClose("root"); 42 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/1/actual.js: -------------------------------------------------------------------------------- 1 | function renderMany(count) { 2 | return ; 3 | } 4 | 5 | function render(data) { 6 | return 7 | {data.count > 5 && renderMany(data.count)} 8 | ; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/1/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function renderMany(count) { 33 | return elementVoid("WowSoMany"); 34 | } 35 | 36 | function render(data) { 37 | elementOpen("root"); 38 | 39 | _renderArbitrary(data.count > 5 && renderMany(data.count)); 40 | 41 | return elementClose("root"); 42 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/conditional-expression/actual.js: -------------------------------------------------------------------------------- 1 | function getDiv() { 2 | return
Bottom
; 3 | } 4 | 5 | function render() { 6 | return
7 | {true ? 8 |
9 |
Top
10 | {getDiv()} 11 |
: 12 | 13 | } 14 | {
? 1 : 2} 15 |
; 16 | } 17 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/logical-expression-sequence-expression-bad/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {true && (1,
, 2)} 4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/logical-expression-sequence-expression-good/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {true && (1, 2,
)} 4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/logical-expression-sequence-expression-good/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | elementOpen("div"); 34 | 35 | _renderArbitrary(true && (1, 2, elementVoid("div"))); 36 | 37 | return elementClose("div"); 38 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/logical-expression/actual.js: -------------------------------------------------------------------------------- 1 | function getDiv() { 2 | return
Bottom
; 3 | } 4 | 5 | function render() { 6 | return
7 | {true && 8 |
9 |
Top
10 | {getDiv()} 11 |
|| 12 | 13 | } 14 |
; 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/logical-expression/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function getDiv() { 33 | elementOpen("div"); 34 | text("Bottom"); 35 | return elementClose("div"); 36 | } 37 | 38 | function render() { 39 | elementOpen("div"); 40 | 41 | _renderArbitrary(true && (elementOpen("div"), (elementOpen("div"), text("Top"), elementClose("div")), _renderArbitrary(getDiv()), elementClose("div")) || elementVoid("other")); 42 | 43 | return elementClose("div"); 44 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/sequence-expression-bad/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {1,
, 2} 4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/sequence-expression-bad/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$wrapper = function _div$wrapper() { 10 | return elementVoid("div"); 11 | }; 12 | 13 | function render() { 14 | elementOpen("div"); 15 | 1; 16 | 17 | _jsxWrapper(_div$wrapper); 18 | 19 | text("2"); 20 | return elementClose("div"); 21 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/sequence-expression-good/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {1, 2,
} 4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/sequence-expression-good/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | 1; 4 | 2; 5 | elementVoid("div"); 6 | return elementClose("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/sequence-expression-logical-expression-bad/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {1, (true &&
), 2} 4 | {1, (false &&
), 2} 5 |
; 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/sequence-expression-logical-expression-bad/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$wrapper = function _div$wrapper() { 10 | return elementVoid("div"); 11 | }, 12 | _div$wrapper2 = function _div$wrapper2() { 13 | return elementVoid("div"); 14 | }; 15 | 16 | function render() { 17 | elementOpen("div"); 18 | 1; 19 | true && _jsxWrapper(_div$wrapper); 20 | text("2"); 21 | 1; 22 | false && _jsxWrapper(_div$wrapper2); 23 | text("2"); 24 | return elementClose("div"); 25 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/sequence-expression-logical-expression-good/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {1, 2, (true &&
)} 4 | {1, 2, (false &&
)} 5 |
; 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/if-then/sequence-expression-logical-expression-good/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | elementOpen("div"); 34 | 1; 35 | 2; 36 | 37 | _renderArbitrary(true && elementVoid("div")); 38 | 39 | 1; 40 | 2; 41 | 42 | _renderArbitrary(false && elementVoid("div")); 43 | 44 | return elementClose("div"); 45 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/infinity/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
{Infinity}
; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/infinity/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | text("Infinity"); 4 | return elementClose("div"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/key-expression/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/key-expression/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", ""]; 2 | 3 | function render() { 4 | var _div$key; 5 | 6 | _div$key = _div$statics[1] = i++; 7 | return elementVoid("div", _div$key, _div$statics); 8 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/nan/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
{NaN}
; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/nan/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | text("NaN"); 4 | return elementClose("div"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/null/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
{null}
; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/null/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | return elementClose("div"); 4 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/number/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
{0}
; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/number/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | text("0"); 4 | return elementClose("div"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/string/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
{"string"}
; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/string/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | text("string"); 4 | return elementClose("div"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/undefined/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
{undefined}
; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/undefined/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | return elementClose("div"); 4 | } -------------------------------------------------------------------------------- /test/fixtures/expression-children/void/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
{void 0}
; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/expression-children/void/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | return elementClose("div"); 4 | } -------------------------------------------------------------------------------- /test/fixtures/expression/each/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | { 4 | queries.forEach(function(query) { 5 | return
; 6 | }) 7 | } 8 |
; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/expression/invocation/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {a()} 4 |
; 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression/invocation/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | elementOpen("div"); 34 | 35 | _renderArbitrary(a()); 36 | 37 | return elementClose("div"); 38 | } -------------------------------------------------------------------------------- /test/fixtures/expression/nested-invocation/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 |
{a()}
4 |
; 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression/nested-invocation/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | elementOpen("div"); 34 | elementOpen("div"); 35 | 36 | _renderArbitrary(a()); 37 | 38 | elementClose("div"); 39 | return elementClose("div"); 40 | } -------------------------------------------------------------------------------- /test/fixtures/expression/nested-object-property/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 |
{data.message}
4 |
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/expression/nested-object-property/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | elementOpen("div"); 34 | elementOpen("div"); 35 | 36 | _renderArbitrary(data.message); 37 | 38 | elementClose("div"); 39 | return elementClose("div"); 40 | } -------------------------------------------------------------------------------- /test/fixtures/expression/nested-variable/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 |
{message}
4 |
; 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression/nested-variable/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | elementOpen("div"); 34 | elementOpen("div"); 35 | 36 | _renderArbitrary(message); 37 | 38 | elementClose("div"); 39 | return elementClose("div"); 40 | } -------------------------------------------------------------------------------- /test/fixtures/expression/number-literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {123} 4 |
; 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression/number-literal/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | text("123"); 4 | return elementClose("div"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression/object-property/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {data.message} 4 |
; 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression/object-property/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | elementOpen("div"); 34 | 35 | _renderArbitrary(data.message); 36 | 37 | return elementClose("div"); 38 | } -------------------------------------------------------------------------------- /test/fixtures/expression/text-literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {"text"} 4 |
; 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression/text-literal/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | text("text"); 4 | return elementClose("div"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression/variable/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
3 | {message} 4 |
; 5 | } -------------------------------------------------------------------------------- /test/fixtures/expression/variable/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | elementOpen("div"); 34 | 35 | _renderArbitrary(message); 36 | 37 | return elementClose("div"); 38 | } -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/disable-inline/child-funciton-level/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | { 4 | files.map((file) => { 5 | // @incremental-dom disable-fastRoot 6 | return
  • fileClicked(e, file)}>{file.name}
  • 7 | }) 8 | } 9 |
; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/disable-inline/child-funciton-level/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/disable-inline/child-level/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | { 4 | // @incremental-dom disable-fastRoot 5 | files.map((file) => { 6 | return
  • fileClicked(e, file)}>{file.name}
  • 7 | }) 8 | } 9 |
; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/disable-inline/child-level/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/disable-inline/function-level/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | // @incremental-dom disable-fastRoot 3 | return
    4 | { 5 | files.map((file) => { 6 | return
  • fileClicked(e, file)}>{file.name}
  • 7 | }) 8 | } 9 |
; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/disable-inline/function-level/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/disable-inline/no-comment/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | { 4 | files.map((file) => { 5 | return
  • fileClicked(e, file)}>{file.name}
  • 6 | }) 7 | } 8 |
; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/disable-inline/no-comment/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/disable-inline/root-level/actual.js: -------------------------------------------------------------------------------- 1 | // @incremental-dom disable-fastRoot 2 | function render() { 3 | return
    4 | { 5 | files.map((file) => { 6 | return
  • fileClicked(e, file)}>{file.name}
  • 7 | }) 8 | } 9 |
; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/disable-inline/root-level/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/enable-inline/child-funciton-level/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | { 4 | files.map((file) => { 5 | // @incremental-dom enable-fastRoot 6 | return
  • fileClicked(e, file)}>{file.name}
  • 7 | }) 8 | } 9 |
; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/enable-inline/child-funciton-level/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": false 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/enable-inline/child-level/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | { 4 | // @incremental-dom enable-fastRoot 5 | files.map((file) => { 6 | return
  • fileClicked(e, file)}>{file.name}
  • 7 | }) 8 | } 9 |
; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/enable-inline/child-level/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": false 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/enable-inline/function-level/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | // @incremental-dom enable-fastRoot 3 | return
    4 | { 5 | files.map((file) => { 6 | return
  • fileClicked(e, file)}>{file.name}
  • 7 | }) 8 | } 9 |
; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/enable-inline/function-level/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": false 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/enable-inline/no-comment/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | { 4 | files.map((file) => { 5 | return
  • fileClicked(e, file)}>{file.name}
  • 6 | }) 7 | } 8 |
; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/enable-inline/no-comment/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": false 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/enable-inline/root-level/actual.js: -------------------------------------------------------------------------------- 1 | // @incremental-dom enable-fastRoot 2 | function render() { 3 | return
    4 | { 5 | files.map((file) => { 6 | return
  • fileClicked(e, file)}>{file.name}
  • 7 | }) 8 | } 9 |
; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/comments/enable-inline/root-level/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": false 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/attribute-nested-attribute/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    { 3 | return
  • fileClicked(e, file)}>{file.name} 5 | }>
  • 6 | })}>
; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/attribute-nested-attribute/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/attribute/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    { 3 | return
  • fileClicked(e, file)}>{file.name}
  • 4 | })}>
; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/attribute/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/element/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | { 4 | files.map((file) => { 5 | return
  • fileClicked(e, file)}>{file.name}
  • 6 | }) 7 | } 8 |
; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/element/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/logical/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | { 4 | true && files.map((file) => ) 5 | } 6 | { 7 | true ? files.map((file) => ) : 1 8 | } 9 | { 10 | 1, (true ? files.map((file) => ) : 1) 11 | } 12 | { 13 | true && (1, files.map((file) => )) 14 | } 15 | { 16 | true ? true && files.map((file) => ) : 1 17 | } 18 |
; 19 | } 20 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/logical/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/nested-attribute-nested-attribute/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    { 3 | return
  • fileClicked(e, file)}>{file.name} 5 | }>
  • 6 | })}>
; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/nested-attribute-nested-attribute/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/nested-attribute/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    { 3 | return
  • 4 | fileClicked(e, file)}>{file.name} 5 |
  • 6 | })}>
; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/nested-attribute/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/nested-child-element/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return 3 | { 4 | files.map((file) => { 5 | return
  • fileClicked(e, file)}>{file.name}
  • 6 | }) 7 | } 8 |
    ; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/nested-child-element/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/nested-element/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
      3 | { 4 | files.map((file) => { 5 | return
    • fileClicked(e, file)}>{file.name}
    • 6 | }) 7 | } 8 |
    ; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/nested-element/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/nested-nested-child-element/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
      3 | { 4 | files.map((file) => { 5 | return
    • fileClicked(e, file)}>{file.name}
    • 6 | }) 7 | } 8 |
    ; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/nested-nested-child-element/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/secondary-element/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var ul =
      3 | { 4 | files.map((file) => { 5 | return
    • fileClicked(e, file)}>{file.name}
    • 6 | }) 7 | } 8 |
    ; 9 | return {ul}; 10 | } 11 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/secondary-element/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/sequence/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
      3 | { 4 | files.map((file) => ), null 5 | } 6 | { 7 | files.map((file) => ), files.map((file) => ) 8 | } 9 | { 10 | null, files.map((file) => ) 11 | } 12 | { 13 | , null 14 | } 15 | { 16 | null, 17 | } 18 | { 19 | null, , null 20 | } 21 |
    ; 22 | } 23 | -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/sequence/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _span$wrapper = function _span$wrapper() { 10 | return elementVoid("span"); 11 | }, 12 | _span$wrapper2 = function _span$wrapper2() { 13 | return elementVoid("span"); 14 | }, 15 | _span$wrapper3 = function _span$wrapper3() { 16 | return elementVoid("span"); 17 | }, 18 | _span$wrapper4 = function _span$wrapper4() { 19 | return elementVoid("span"); 20 | }; 21 | 22 | function render() { 23 | elementOpen("ul"); 24 | files.map(function (file) { 25 | return _jsxWrapper(_span$wrapper); 26 | }); 27 | files.map(function (file) { 28 | return _jsxWrapper(_span$wrapper2); 29 | }); 30 | files.map(function (file) { 31 | return elementVoid("span"); 32 | }); 33 | null; 34 | files.map(function (file) { 35 | return elementVoid("span"); 36 | }); 37 | 38 | _jsxWrapper(_span$wrapper3); 39 | 40 | null; 41 | elementVoid("span"); 42 | null; 43 | 44 | _jsxWrapper(_span$wrapper4); 45 | 46 | return elementClose("ul"); 47 | } -------------------------------------------------------------------------------- /test/fixtures/fast-root/true/sequence/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "fastRoot": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/idom-methods/global/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    test
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/idom-methods/global/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | text("test"); 4 | return elementClose("div"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/idom-methods/import-namespace-with-prefix/actual.js: -------------------------------------------------------------------------------- 1 | import * as iDOM from "incremental-dom"; 2 | 3 | function render() { 4 | return
    test
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/idom-methods/import-namespace-with-prefix/expected.js: -------------------------------------------------------------------------------- 1 | var iDOM = _interopRequireWildcard(require("incremental-dom")); 2 | 3 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } 4 | 5 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 6 | 7 | function render() { 8 | (0, iDOM.elementOpen)("div"); 9 | (0, iDOM.text)("test"); 10 | return (0, iDOM.elementClose)("div"); 11 | } -------------------------------------------------------------------------------- /test/fixtures/idom-methods/import-specifier/actual.js: -------------------------------------------------------------------------------- 1 | import { elementOpen as eo, elementClose, text } from "incremental-dom"; 2 | 3 | function scope() { 4 | var eo = other; 5 | var elementClose = other; 6 | function render() { 7 | return
    test
    ; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/idom-methods/import-specifier/expected.js: -------------------------------------------------------------------------------- 1 | var _incrementalDom = require("incremental-dom"); 2 | 3 | function scope() { 4 | var eo = other; 5 | var elementClose = other; 6 | 7 | function render() { 8 | (0, _incrementalDom.elementOpen)("div"); 9 | (0, _incrementalDom.text)("test"); 10 | return (0, _incrementalDom.elementClose)("div"); 11 | } 12 | } -------------------------------------------------------------------------------- /test/fixtures/idom-methods/require/actual.js: -------------------------------------------------------------------------------- 1 | const { elementOpen, elementClose, text } = require('incremental-dom'); 2 | 3 | function render() { 4 | return
    test
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/idom-methods/require/expected.js: -------------------------------------------------------------------------------- 1 | var _require = require('incremental-dom'), 2 | elementOpen = _require.elementOpen, 3 | elementClose = _require.elementClose, 4 | text = _require.text; 5 | 6 | function render() { 7 | elementOpen("div"); 8 | text("test"); 9 | return elementClose("div"); 10 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/assigned-conditionally/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div; 3 | if (condition) { 4 | div =
    ; 5 | } 6 | return {div}; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/assigned-conditionally/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/assigned-staticly/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div; 3 | div =
    ; 4 | return {div}; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/assigned-staticly/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/call-hoisted/actual.js: -------------------------------------------------------------------------------- 1 | function div() { 2 | return
    ; 3 | } 4 | 5 | function render() { 6 | return {div()}; 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/call-hoisted/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function div() { 33 | return elementVoid("div"); 34 | } 35 | 36 | function render() { 37 | elementOpen("root"); 38 | 39 | _renderArbitrary(div()); 40 | 41 | return elementClose("root"); 42 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/call-hoisted/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/call-iife/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return {function div() { 3 | return
    ; 4 | }()}; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/call-iife/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/call/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | function div() { 3 | return
    ; 4 | } 5 | return {div()}; 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/call/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/eager-children/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var i = 0; 3 | var div =
    ; 4 | return {div}; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/eager-children/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var i = 0; 3 | 4 | var _attr = i++, 5 | _other = i++; 6 | 7 | elementOpen("root", null, null, "attr", i++); 8 | elementVoid("div", null, null, "attr", _attr, "other", _other); 9 | return elementClose("root"); 10 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/eager-children/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/element-with-inline/actual.js: -------------------------------------------------------------------------------- 1 | function render(id) { 2 | var key = id; 3 | const div =
    ; 4 | return {div}; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/element-with-inline/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", ""]; 2 | 3 | function render(id) { 4 | var key = id; 5 | var _key = key; 6 | elementOpen("root"); 7 | _div$statics[1] = _key; 8 | elementVoid("div", _key, _div$statics); 9 | return elementClose("root"); 10 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/element-with-inline/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/element/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | const div =
    ; 3 | return {div}; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/element/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("root"); 3 | elementVoid("div"); 4 | return elementClose("root"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/element/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/function-nested-elements/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | const ul =
      {lis.map((li) => { 3 | return
    • 4 | })}
    ; 5 | return {ul}; 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/function-nested-elements/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/function-param/actual.js: -------------------------------------------------------------------------------- 1 | function render(param) { 2 | return {param}; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/function-param/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render(param) { 33 | elementOpen("root"); 34 | 35 | _renderArbitrary(param); 36 | 37 | return elementClose("root"); 38 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/function-param/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/global/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return {div}; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/global/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | elementOpen("root"); 34 | 35 | _renderArbitrary(div); 36 | 37 | return elementClose("root"); 38 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/global/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/hoisted/actual.js: -------------------------------------------------------------------------------- 1 | const div =
    ; 2 | 3 | function render() { 4 | return {div}; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/hoisted/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("root"); 3 | elementVoid("div"); 4 | return elementClose("root"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/hoisted/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/inline-in-wrapper/actual.js: -------------------------------------------------------------------------------- 1 | function render(key) { 2 | var text = key; 3 | var div; 4 | div =
    {text}
    ; 5 | return {div}; 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/inline-in-wrapper/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div = `test${i++}`; 3 | return {div}; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/literal/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | var div = "test".concat(i++); 34 | elementOpen("root"); 35 | 36 | _renderArbitrary(div); 37 | 38 | return elementClose("root"); 39 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/literal/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/nested-elements/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | const ul =
    • test
    ; 3 | return {ul}; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/nested-elements/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("root"); 3 | elementOpen("ul"); 4 | elementOpen("li"); 5 | text("test"); 6 | elementClose("li"); 7 | elementClose("ul"); 8 | return elementClose("root"); 9 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/nested-elements/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/undefined/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div; 3 | return {div}; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/undefined/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | var div; 34 | elementOpen("root"); 35 | 36 | _renderArbitrary(div); 37 | 38 | return elementClose("root"); 39 | } -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/undefined/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/wrapper-with-eager-expressions/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div; 3 | div =
    ; 4 | return {div}; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/wrapper-with-eager-expressions/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/wrapper/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div; 3 | div =
    ; 4 | return {div}; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/inline-expressions/wrapper/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "inlineExpressions": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/issues/37/actual.js: -------------------------------------------------------------------------------- 1 | function renderMain() { 2 | const renderInput = () => ( 3 |
    4 | 5 |
    6 | ); 7 | return
    8 | {renderInput()} 9 |
    ; 10 | } 11 | 12 | const renderInput = () => ( 13 |
    14 | 15 |
    16 | ); 17 | 18 | function renderMain2() { 19 | return
    20 | {renderInput()} 21 |
    ; 22 | } 23 | 24 | 25 | // - - - - - - - 26 | 27 | function renderMain3(flag) { 28 | if (flag) { 29 | return
    ; 30 | } 31 | return
    32 | {renderInput()} 33 |
    ; 34 | } 35 | -------------------------------------------------------------------------------- /test/fixtures/issues/41/actual.js: -------------------------------------------------------------------------------- 1 | function renderMain() { 2 | return

    before 3 | middle 4 | after.

    5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/issues/41/expected.js: -------------------------------------------------------------------------------- 1 | function renderMain() { 2 | elementOpen("p"); 3 | text("before "); 4 | elementOpen("span"); 5 | text(" middle "); 6 | elementClose("span"); 7 | text(" after."); 8 | return elementClose("p"); 9 | } -------------------------------------------------------------------------------- /test/fixtures/issues/96/actual.js: -------------------------------------------------------------------------------- 1 | 2 | function renderMain() { 3 | function renderState({ bar }) { 4 | return ([ 5 | one, 8 | two, 11 | three 14 | ]); 15 | } 16 | 17 | const state = { 18 | bar: 'Hello World' 19 | }; 20 | 21 | return renderState(state); 22 | } 23 | -------------------------------------------------------------------------------- /test/fixtures/issues/96/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _span$wrapper = function _span$wrapper(_MyBarIs$concat) { 10 | elementOpen("span", null, null, "foo", _MyBarIs$concat); 11 | text("one"); 12 | return elementClose("span"); 13 | }, 14 | _span$wrapper2 = function _span$wrapper2(_foo) { 15 | elementOpen("span", null, null, "foo", _foo); 16 | text("two"); 17 | return elementClose("span"); 18 | }, 19 | _span$wrapper3 = function _span$wrapper3(_foo2) { 20 | elementOpen("span", null, null, "foo", _foo2); 21 | text("three"); 22 | return elementClose("span"); 23 | }; 24 | 25 | function renderMain() { 26 | function renderState(_ref) { 27 | var bar = _ref.bar; 28 | return [_jsxWrapper(_span$wrapper, ["My bar is: ".concat(bar)]), _jsxWrapper(_span$wrapper2, ["My bar is: ".concat(bar)]), _jsxWrapper(_span$wrapper3, ["My bar is: ".concat(bar)])]; 29 | } 30 | 31 | var state = { 32 | bar: 'Hello World' 33 | }; 34 | return renderState(state); 35 | } -------------------------------------------------------------------------------- /test/fixtures/key/mutate/jsx-in-attribute-updates-key/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    } key={i++} /> 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/key/mutate/jsx-in-attribute-updates-key/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$wrapper = function _div$wrapper(_attr) { 10 | return elementVoid("div", null, null, "attr", _attr); 11 | }, 12 | _div$statics = ["key", ""]; 13 | 14 | function render() { 15 | var _attr2, _div$key; 16 | 17 | _attr2 = _jsxWrapper(_div$wrapper, [i++]); 18 | _div$key = _div$statics[1] = i++; 19 | return elementVoid("div", _div$key, _div$statics, "attr2", _attr2); 20 | } -------------------------------------------------------------------------------- /test/fixtures/key/mutate/nested-other-attr-updates-key/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    4 |
    5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/key/mutate/nested-other-attr-updates-key/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", ""]; 2 | 3 | function render() { 4 | var _attr, _div$key; 5 | 6 | elementOpen("div", null, null, "attr", i++); 7 | _attr = i++; 8 | _div$key = _div$statics[1] = i++; 9 | elementVoid("div", _div$key, _div$statics, "attr2", _attr); 10 | return elementClose("div"); 11 | } -------------------------------------------------------------------------------- /test/fixtures/key/mutate/other-attr-updates-key/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/key/mutate/other-attr-updates-key/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", ""]; 2 | 3 | function render() { 4 | var _attr, _div$key; 5 | 6 | _attr = i++; 7 | _div$key = _div$statics[1] = i++; 8 | return elementVoid("div", _div$key, _div$statics, "attr", _attr); 9 | } -------------------------------------------------------------------------------- /test/fixtures/key/mutate/other-attr/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    ; 3 | } 4 | 5 | function render2() { 6 | return
    ; 7 | } 8 | 9 | function render3() { 10 | return
    ; 11 | } 12 | 13 | function render4() { 14 | return
    ; 15 | } 16 | -------------------------------------------------------------------------------- /test/fixtures/key/mutate/other-attr/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", ""], 2 | _div$statics2 = ["key", ""], 3 | _div$statics3 = ["key", ""], 4 | _div$statics4 = ["key", ""]; 5 | 6 | function render() { 7 | var _attr, _div$key; 8 | 9 | _attr = i; 10 | _div$key = _div$statics[1] = i++; 11 | return elementVoid("div", _div$key, _div$statics, "attr", _attr); 12 | } 13 | 14 | function render2() { 15 | var _div$key2; 16 | 17 | _div$key2 = _div$statics2[1] = i++; 18 | return elementVoid("div", _div$key2, _div$statics2, "attr", i); 19 | } 20 | 21 | function render3() { 22 | var _attr2; 23 | 24 | _attr2 = _div$statics3[1] = i++; 25 | return elementVoid("div", i, _div$statics3, "attr", _attr2); 26 | } 27 | 28 | function render4() { 29 | _div$statics4[1] = i; 30 | return elementVoid("div", i, _div$statics4, "attr", i++); 31 | } -------------------------------------------------------------------------------- /test/fixtures/key/mutate/spread-attributes-member-mutated-key/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/key/mutate/spread-attributes-member-mutated-key/expected.js: -------------------------------------------------------------------------------- 1 | var _hasOwn = Object.prototype.hasOwnProperty; 2 | 3 | var _spreadAttribute = function _spreadAttribute(spread) { 4 | for (var prop in spread) { 5 | if (_hasOwn.call(spread, prop)) attr(prop, spread[prop]); 6 | } 7 | }; 8 | 9 | var _div$statics = ["key", ""]; 10 | 11 | function render() { 12 | var _spread, _div$key; 13 | 14 | _spread = props.props; 15 | _div$key = _div$statics[1] = props.key++; 16 | elementOpenStart("div", _div$key, _div$statics); 17 | 18 | _spreadAttribute(_spread); 19 | 20 | elementOpenEnd("div"); 21 | return elementClose("div"); 22 | } -------------------------------------------------------------------------------- /test/fixtures/key/mutate/spread-attributes-mutated-key/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/key/mutate/spread-attributes-mutated-key/expected.js: -------------------------------------------------------------------------------- 1 | var _hasOwn = Object.prototype.hasOwnProperty; 2 | 3 | var _spreadAttribute = function _spreadAttribute(spread) { 4 | for (var prop in spread) { 5 | if (_hasOwn.call(spread, prop)) attr(prop, spread[prop]); 6 | } 7 | }; 8 | 9 | var _div$statics = ["key", ""]; 10 | 11 | function render() { 12 | var _spread, _div$key; 13 | 14 | _spread = props; 15 | _div$key = _div$statics[1] = props.key++; 16 | elementOpenStart("div", _div$key, _div$statics); 17 | 18 | _spreadAttribute(_spread); 19 | 20 | elementOpenEnd("div"); 21 | return elementClose("div"); 22 | } -------------------------------------------------------------------------------- /test/fixtures/key/mutate/wrapper-other-attr-updates-key/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div =
    3 |
    4 |
    ; 5 | return {div}; 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/key/mutate/wrapper-spread-attribute-updates-key/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div =
    3 |
    4 |
    ; 5 | return {div}; 6 | } 7 | -------------------------------------------------------------------------------- /test/fixtures/key/nested-object-property/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    4 |
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/key/nested-object-property/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", ""]; 2 | 3 | function render() { 4 | var _div$key; 5 | 6 | elementOpen("div"); 7 | _div$key = _div$statics[1] = props.key; 8 | elementOpen("div", _div$key, _div$statics); 9 | elementClose("div"); 10 | return elementClose("div"); 11 | } -------------------------------------------------------------------------------- /test/fixtures/key/nested-string-literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    4 |
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/key/nested-string-literal/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", "1"]; 2 | 3 | function render() { 4 | elementOpen("div"); 5 | elementOpen("div", "1", _div$statics); 6 | elementClose("div"); 7 | return elementClose("div"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/key/nested-string/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    4 |
    ; 5 | } -------------------------------------------------------------------------------- /test/fixtures/key/nested-string/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", "1"]; 2 | 3 | function render() { 4 | elementOpen("div"); 5 | elementOpen("div", "1", _div$statics); 6 | elementClose("div"); 7 | return elementClose("div"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/key/nexted-number-literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    4 |
    ; 5 | } -------------------------------------------------------------------------------- /test/fixtures/key/nexted-number-literal/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", "1"]; 2 | 3 | function render() { 4 | elementOpen("div"); 5 | elementOpen("div", "1", _div$statics); 6 | elementClose("div"); 7 | return elementClose("div"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/key/nexted-variable/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    4 |
    ; 5 | } -------------------------------------------------------------------------------- /test/fixtures/key/nexted-variable/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", ""]; 2 | 3 | function render() { 4 | elementOpen("div"); 5 | _div$statics[1] = key; 6 | elementOpen("div", key, _div$statics); 7 | elementClose("div"); 8 | return elementClose("div"); 9 | } -------------------------------------------------------------------------------- /test/fixtures/key/number-literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | } -------------------------------------------------------------------------------- /test/fixtures/key/number-literal/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", "1"]; 2 | 3 | function render() { 4 | return elementVoid("div", "1", _div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/key/object-property/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | } -------------------------------------------------------------------------------- /test/fixtures/key/object-property/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", ""]; 2 | 3 | function render() { 4 | var _div$key; 5 | 6 | _div$key = _div$statics[1] = props.key; 7 | return elementVoid("div", _div$key, _div$statics); 8 | } -------------------------------------------------------------------------------- /test/fixtures/key/string-literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/key/string-literal/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", "1"]; 2 | 3 | function render() { 4 | return elementVoid("div", "1", _div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/key/string/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | } -------------------------------------------------------------------------------- /test/fixtures/key/string/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", "1"]; 2 | 3 | function render() { 4 | return elementVoid("div", "1", _div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/key/variable/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | } -------------------------------------------------------------------------------- /test/fixtures/key/variable/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", ""]; 2 | 3 | function render() { 4 | _div$statics[1] = key; 5 | return elementVoid("div", key, _div$statics); 6 | } -------------------------------------------------------------------------------- /test/fixtures/module-source/absolute/actual.js: -------------------------------------------------------------------------------- 1 | function scope() { 2 | return
    test
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/module-source/absolute/expected.js: -------------------------------------------------------------------------------- 1 | var _idomWrapper = require("/idom-wrapper"); 2 | 3 | function scope() { 4 | (0, _idomWrapper.elementOpen)("div"); 5 | (0, _idomWrapper.text)("test"); 6 | return (0, _idomWrapper.elementClose)("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/module-source/absolute/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "moduleSource": "/idom-wrapper" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/module-source/global/actual.js: -------------------------------------------------------------------------------- 1 | function scope() { 2 | return
    test
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/module-source/global/expected.js: -------------------------------------------------------------------------------- 1 | var _idomWrapper = require("idom-wrapper"); 2 | 3 | function scope() { 4 | (0, _idomWrapper.elementOpen)("div"); 5 | (0, _idomWrapper.text)("test"); 6 | return (0, _idomWrapper.elementClose)("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/module-source/global/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "moduleSource": "idom-wrapper" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/module-source/relative/actual.js: -------------------------------------------------------------------------------- 1 | function scope() { 2 | return
    test
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/module-source/relative/expected.js: -------------------------------------------------------------------------------- 1 | var _idomWrapper = require("../../../../idom-wrapper"); 2 | 3 | function scope() { 4 | (0, _idomWrapper.elementOpen)("div"); 5 | (0, _idomWrapper.text)("test"); 6 | return (0, _idomWrapper.elementClose)("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/module-source/relative/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "moduleSource": "./idom-wrapper" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/namespace-attributes/attribute/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/namespace-attributes/attribute/expected.js: -------------------------------------------------------------------------------- 1 | var _input$statics = ["a:type", "text"]; 2 | 3 | function render() { 4 | return elementVoid("input", "__uuid__0__", _input$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/namespace-attributes/attribute/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "namespaceAttributes": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/69/actual.js: -------------------------------------------------------------------------------- 1 | import { patch } from "incremental-dom"; 2 | 3 | const obj = { 4 | get template() { 5 | return Hello; 6 | }, 7 | 8 | render() { 9 | patch(this.container, () => { 10 | return
    {this.template}
    ; 11 | }); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/class/actual.js: -------------------------------------------------------------------------------- 1 | import { patch } from "incremental-dom"; 2 | 3 | class Component { 4 | template(data) { 5 | return
    6 | {items.map(x =>
  • x.text
  • )} 7 |
    ; 8 | } 9 | 10 | render() { 11 | patch(this.element, this.template, this.data); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/extracted-render/actual.js: -------------------------------------------------------------------------------- 1 | import { patch } from "incremental-dom"; 2 | 3 | function render(items) { 4 | return
    5 | {items.map(x =>
  • x.text
  • )} 6 |
    ; 7 | } 8 | 9 | patch(container, render, items); 10 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/fast-root/actual.js: -------------------------------------------------------------------------------- 1 | import { patch } from "incremental-dom"; 2 | 3 | const todoItems = function(items) { 4 | // @incremental-dom enable-fastRoot 5 | return items.map(x =>
  • x.text
  • ); 6 | } 7 | 8 | patch(container, () => { 9 | return
    {todoItems(items)}
    ; 10 | }); 11 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/import-specifier/actual.js: -------------------------------------------------------------------------------- 1 | import { patch } from "incremental-dom"; 2 | 3 | const todoItems = items.map(x =>
  • x.text
  • ); 4 | 5 | patch(container, () => { 6 | return
    {todoItems}
    ; 7 | }); 8 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/import-wildcard/actual.js: -------------------------------------------------------------------------------- 1 | import * as iDOM from "incremental-dom"; 2 | 3 | const todoItems = items.map(x =>
  • x.text
  • ); 4 | 5 | iDOM.patch(container, () => { 6 | return
    {todoItems}
    ; 7 | }); 8 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/module-source-import-specifier/actual.js: -------------------------------------------------------------------------------- 1 | import { patch } from "idom-wrapper"; 2 | 3 | const todoItems = items.map(x =>
  • x.text
  • ); 4 | 5 | patch(container, () => { 6 | return
    {todoItems}
    ; 7 | }); 8 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/module-source-import-specifier/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "moduleSource": "idom-wrapper" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/module-source-import-wildcard/actual.js: -------------------------------------------------------------------------------- 1 | import * as iDOM from "idom-wrapper"; 2 | 3 | const todoItems = items.map(x =>
  • x.text
  • ); 4 | 5 | iDOM.patch(container, () => { 6 | return
    {todoItems}
    ; 7 | }); 8 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/module-source-import-wildcard/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "moduleSource": "idom-wrapper" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/no-import/actual.js: -------------------------------------------------------------------------------- 1 | const todoItems = items.map(x =>
  • x.text
  • ); 2 | 3 | iDOM.patch(container, () => { 4 | return
    {todoItems}
    ; 5 | }); 6 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/no-import/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | var todoItems = items.map(function (x) { 33 | elementOpen("li"); 34 | text("x.text"); 35 | return elementClose("li"); 36 | }); 37 | iDOM.patch(container, function () { 38 | elementOpen("div"); 39 | 40 | _renderArbitrary(todoItems); 41 | 42 | return elementClose("div"); 43 | }); -------------------------------------------------------------------------------- /test/fixtures/patch-root/object/actual.js: -------------------------------------------------------------------------------- 1 | import { patch } from "incremental-dom"; 2 | 3 | function Component() { 4 | } 5 | 6 | Component.prototype.template = function(data) { 7 | return
    8 | {items.map(x =>
  • x.text
  • )} 9 |
    ; 10 | } 11 | 12 | Component.prototype.render = function() { 13 | patch(this.element, this.template, this.data); 14 | } 15 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/requires-root-node/actual.js: -------------------------------------------------------------------------------- 1 | import { patch } from "incremental-dom"; 2 | 3 | function todoItems() { 4 | return items.map(x =>
  • x.text
  • ); 5 | } 6 | 7 | patch(container, () => {todoItems()}); 8 | -------------------------------------------------------------------------------- /test/fixtures/patch-root/requires-root-node/expected.js: -------------------------------------------------------------------------------- 1 | var _incrementalDom = require("incremental-dom"); 2 | 3 | var _jsxWrapper = function _jsxWrapper(func, args) { 4 | return { 5 | __jsxDOMWrapper: true, 6 | func: func, 7 | args: args 8 | }; 9 | }; 10 | 11 | var _li$wrapper = function _li$wrapper() { 12 | (0, _incrementalDom.elementOpen)("li"); 13 | (0, _incrementalDom.text)("x.text"); 14 | return (0, _incrementalDom.elementClose)("li"); 15 | }; 16 | 17 | function todoItems() { 18 | return items.map(function (x) { 19 | return _jsxWrapper(_li$wrapper); 20 | }); 21 | } 22 | 23 | (0, _incrementalDom.patch)(container, function () { 24 | todoItems(); 25 | }); -------------------------------------------------------------------------------- /test/fixtures/program/element/actual.js: -------------------------------------------------------------------------------- 1 | var div =
    ; 2 | -------------------------------------------------------------------------------- /test/fixtures/program/element/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$wrapper = function _div$wrapper() { 10 | elementOpen("div"); 11 | return elementClose("div"); 12 | }; 13 | 14 | var div = _jsxWrapper(_div$wrapper); -------------------------------------------------------------------------------- /test/fixtures/program/expression-children/actual.js: -------------------------------------------------------------------------------- 1 | var div =
    ; 2 | -------------------------------------------------------------------------------- /test/fixtures/program/expression-children/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$statics = ["key", ""], 10 | _div$wrapper = function _div$wrapper(_key) { 11 | _div$statics[1] = _key; 12 | elementOpen("div", _key, _div$statics); 13 | return elementClose("div"); 14 | }; 15 | 16 | var div = _jsxWrapper(_div$wrapper, [i++]); -------------------------------------------------------------------------------- /test/fixtures/program/hoist/actual.js: -------------------------------------------------------------------------------- 1 | var div =
    ; 2 | -------------------------------------------------------------------------------- /test/fixtures/program/hoist/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$statics = ["key", ""], 10 | _div$wrapper = function _div$wrapper(_key) { 11 | _div$statics[1] = _key; 12 | elementOpen("div", _key, _div$statics); 13 | return elementClose("div"); 14 | }; 15 | 16 | var div = _jsxWrapper(_div$wrapper, [i++]); -------------------------------------------------------------------------------- /test/fixtures/program/hoist/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "hoist": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/runtime/module/expression-child/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    {test}
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/runtime/module/expression-child/expected.js: -------------------------------------------------------------------------------- 1 | var _iDOM = require("iDOM"); 2 | 3 | function render() { 4 | elementOpen("div"); 5 | (0, _iDOM.renderArbitrary)(test); 6 | return elementClose("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/runtime/module/expression-child/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "runtimeModuleSource": "iDOM" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/runtime/module/spread/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/runtime/module/spread/expected.js: -------------------------------------------------------------------------------- 1 | var _iDOM = require("iDOM"); 2 | 3 | function render() { 4 | elementOpenStart("div"); 5 | (0, _iDOM.spreadAttribute)(props); 6 | elementOpenEnd("div"); 7 | return elementClose("div"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/runtime/module/spread/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "runtimeModuleSource": "iDOM" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/runtime/module/wrapper-eager/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div =
    ; 3 | return
    ; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/runtime/module/wrapper-eager/expected.js: -------------------------------------------------------------------------------- 1 | var _iDOM = require("iDOM"); 2 | 3 | var _div$wrapper = function _div$wrapper(_attr) { 4 | return elementVoid("div", null, null, "attr", _attr); 5 | }; 6 | 7 | function render() { 8 | var div = (0, _iDOM.jsxWrapper)(_div$wrapper, [i++]); 9 | return elementVoid("div"); 10 | } -------------------------------------------------------------------------------- /test/fixtures/runtime/module/wrapper-eager/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "runtimeModuleSource": "iDOM" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/runtime/module/wrapper/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var div =
    ; 3 | return
    ; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/runtime/module/wrapper/expected.js: -------------------------------------------------------------------------------- 1 | var _iDOM = require("iDOM"); 2 | 3 | var _div$wrapper = function _div$wrapper() { 4 | return elementVoid("div"); 5 | }; 6 | 7 | function render() { 8 | var div = (0, _iDOM.jsxWrapper)(_div$wrapper); 9 | return elementVoid("div"); 10 | } -------------------------------------------------------------------------------- /test/fixtures/runtime/module/wrapper/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "runtimeModuleSource": "iDOM" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/self-closing-element/nested-attribute/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    4 |
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/self-closing-element/nested-attribute/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["attr", "value"]; 2 | 3 | function render() { 4 | elementOpen("div"); 5 | elementVoid("div", "__uuid__0__", _div$statics); 6 | return elementClose("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/self-closing-element/nested-self-closing/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    4 |
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/self-closing-element/nested-self-closing/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | elementVoid("div"); 4 | return elementClose("div"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/self-closing-element/root-attribute/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/self-closing-element/root-attribute/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["attr", "value"]; 2 | 3 | function render() { 4 | return elementVoid("div", "__uuid__0__", _div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/self-closing-element/root/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/self-closing-element/root/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return elementVoid("div"); 3 | } -------------------------------------------------------------------------------- /test/fixtures/sequence-expressions/assignment-good/actual.js: -------------------------------------------------------------------------------- 1 | function fn() { 2 | var a; 3 | var b = (a =
    , 1); 4 | } -------------------------------------------------------------------------------- /test/fixtures/sequence-expressions/assignment-good/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _a$wrapper = function _a$wrapper() { 10 | return elementVoid("div"); 11 | }; 12 | 13 | function fn() { 14 | var a; 15 | var b = (a = _jsxWrapper(_a$wrapper), 1); 16 | } -------------------------------------------------------------------------------- /test/fixtures/sequence-expressions/explicit-arrow-root-good/actual.js: -------------------------------------------------------------------------------- 1 | var fn = () => { 2 | return (1, ); 3 | }; -------------------------------------------------------------------------------- /test/fixtures/sequence-expressions/explicit-arrow-root-good/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _good$wrapper = function _good$wrapper() { 10 | return elementVoid("good"); 11 | }; 12 | 13 | var fn = function fn() { 14 | return 1, _jsxWrapper(_good$wrapper); 15 | }; -------------------------------------------------------------------------------- /test/fixtures/sequence-expressions/implicit-arrow-root-good/actual.js: -------------------------------------------------------------------------------- 1 | var fn = () => (1, ); -------------------------------------------------------------------------------- /test/fixtures/sequence-expressions/implicit-arrow-root-good/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _good$wrapper = function _good$wrapper() { 10 | return elementVoid("good"); 11 | }; 12 | 13 | var fn = function fn() { 14 | return 1, _jsxWrapper(_good$wrapper); 15 | }; -------------------------------------------------------------------------------- /test/fixtures/sequence-expressions/root-bad/actual.js: -------------------------------------------------------------------------------- 1 | function fn() { 2 | var b = (, 1); 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/sequence-expressions/root-bad/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _b$wrapper = function _b$wrapper() { 10 | return elementVoid("bad"); 11 | }; 12 | 13 | function fn() { 14 | var b = (_jsxWrapper(_b$wrapper), 1); 15 | } -------------------------------------------------------------------------------- /test/fixtures/sequence-expressions/root-good/actual.js: -------------------------------------------------------------------------------- 1 | function fn() { 2 | return (1, ); 3 | } -------------------------------------------------------------------------------- /test/fixtures/sequence-expressions/root-good/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _good$wrapper = function _good$wrapper() { 10 | return elementVoid("good"); 11 | }; 12 | 13 | function fn() { 14 | return 1, _jsxWrapper(_good$wrapper); 15 | } -------------------------------------------------------------------------------- /test/fixtures/sibling-root-elements/hoisted-nested-function/actual.js: -------------------------------------------------------------------------------- 1 | function fn5() { 2 | var a = inner(); 3 | return ; 4 | function inner() { 5 | return
    ; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/sibling-root-elements/hoisted-nested-function/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$wrapper = function _div$wrapper() { 10 | return elementVoid("div"); 11 | }; 12 | 13 | function fn5() { 14 | var a = inner(); 15 | elementOpen("root"); 16 | return elementClose("root"); 17 | 18 | function inner() { 19 | return _jsxWrapper(_div$wrapper); 20 | } 21 | } -------------------------------------------------------------------------------- /test/fixtures/sibling-root-elements/if-statement/actual.js: -------------------------------------------------------------------------------- 1 | function fn() { 2 | if (test) { 3 | return ; 4 | } else { 5 | return ; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/fixtures/sibling-root-elements/if-statement/expected.js: -------------------------------------------------------------------------------- 1 | function fn() { 2 | if (test) { 3 | return elementVoid("consequent"); 4 | } else { 5 | return elementVoid("alternate"); 6 | } 7 | } -------------------------------------------------------------------------------- /test/fixtures/sibling-root-elements/nested-function/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | function fn1() { 3 | return
    ; 4 | } 5 | function fn2() { 6 | return
    7 | } 8 | return ; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/sibling-root-elements/nested-function/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$wrapper = function _div$wrapper() { 10 | return elementVoid("div"); 11 | }, 12 | _div$wrapper2 = function _div$wrapper2() { 13 | elementOpen("div"); 14 | return elementClose("div"); 15 | }; 16 | 17 | function render() { 18 | function fn1() { 19 | return _jsxWrapper(_div$wrapper); 20 | } 21 | 22 | function fn2() { 23 | return _jsxWrapper(_div$wrapper2); 24 | } 25 | 26 | elementOpen("root"); 27 | return elementClose("root"); 28 | } -------------------------------------------------------------------------------- /test/fixtures/sibling-root-elements/nested-loop-function/actual.js: -------------------------------------------------------------------------------- 1 | function fn4() { 2 | var items = items.map((item) => { 3 | return
    ; 4 | }); 5 | return ; 6 | } -------------------------------------------------------------------------------- /test/fixtures/sibling-root-elements/nested-loop-function/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$wrapper = function _div$wrapper() { 10 | return elementVoid("div"); 11 | }; 12 | 13 | function fn4() { 14 | var items = items.map(function (item) { 15 | return _jsxWrapper(_div$wrapper); 16 | }); 17 | return elementVoid("root"); 18 | } -------------------------------------------------------------------------------- /test/fixtures/sibling-root-elements/normal/actual.js: -------------------------------------------------------------------------------- 1 | function fn() { 2 | return ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/sibling-root-elements/normal/expected.js: -------------------------------------------------------------------------------- 1 | function fn() { 2 | return elementVoid("root"); 3 | } -------------------------------------------------------------------------------- /test/fixtures/skip/custom/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/skip/custom/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["skip", "true"]; 2 | 3 | function render() { 4 | elementOpen("div", "__uuid__0__", _div$statics); 5 | skip(); 6 | return elementClose("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/skip/custom/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "skipAttribute": "skip" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/skip/default/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/skip/default/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["__skip", "true"]; 2 | 3 | function render() { 4 | elementOpen("div", "__uuid__0__", _div$statics); 5 | skip(); 6 | return elementClose("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/skip/self-closing/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/skip/self-closing/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["__skip", "true"]; 2 | 3 | function render() { 4 | elementOpen("div", "__uuid__0__", _div$statics); 5 | skip(); 6 | return elementClose("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/spread-attributes/call/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var test =
    ; 3 | return
    ; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/spread-attributes/call/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _hasOwn = Object.prototype.hasOwnProperty; 10 | 11 | var _spreadAttribute = function _spreadAttribute(spread) { 12 | for (var prop in spread) { 13 | if (_hasOwn.call(spread, prop)) attr(prop, spread[prop]); 14 | } 15 | }; 16 | 17 | var _test$wrapper = function _test$wrapper(_props) { 18 | elementOpenStart("div"); 19 | 20 | _spreadAttribute(_props); 21 | 22 | elementOpenEnd("div"); 23 | return elementClose("div"); 24 | }; 25 | 26 | function render() { 27 | var test = _jsxWrapper(_test$wrapper, [props()]); 28 | 29 | elementOpenStart("div"); 30 | 31 | _spreadAttribute(props()); 32 | 33 | elementOpenEnd("div"); 34 | return elementClose("div"); 35 | } -------------------------------------------------------------------------------- /test/fixtures/spread-attributes/combined-attributes/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    ; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/spread-attributes/combined-attributes/expected.js: -------------------------------------------------------------------------------- 1 | var _hasOwn = Object.prototype.hasOwnProperty; 2 | 3 | var _spreadAttribute = function _spreadAttribute(spread) { 4 | for (var prop in spread) { 5 | if (_hasOwn.call(spread, prop)) attr(prop, spread[prop]); 6 | } 7 | }; 8 | 9 | var _div$statics = ["class", "test", "key", "test"]; 10 | 11 | function render() { 12 | elementOpenStart("div", "test", _div$statics); 13 | attr("id", id); 14 | 15 | _spreadAttribute(props); 16 | 17 | attr("data-expanded", expanded); 18 | 19 | _spreadAttribute(props.attrs); 20 | 21 | elementOpenEnd("div"); 22 | return elementClose("div"); 23 | } -------------------------------------------------------------------------------- /test/fixtures/spread-attributes/self-closing/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/spread-attributes/self-closing/expected.js: -------------------------------------------------------------------------------- 1 | var _hasOwn = Object.prototype.hasOwnProperty; 2 | 3 | var _spreadAttribute = function _spreadAttribute(spread) { 4 | for (var prop in spread) { 5 | if (_hasOwn.call(spread, prop)) attr(prop, spread[prop]); 6 | } 7 | }; 8 | 9 | function render() { 10 | elementOpenStart("div"); 11 | 12 | _spreadAttribute(props); 13 | 14 | elementOpenEnd("div"); 15 | return elementClose("div"); 16 | } -------------------------------------------------------------------------------- /test/fixtures/spread-attributes/variable/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | var test =
    ; 3 | return
    ; 4 | } 5 | -------------------------------------------------------------------------------- /test/fixtures/spread-attributes/variable/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _hasOwn = Object.prototype.hasOwnProperty; 10 | 11 | var _spreadAttribute = function _spreadAttribute(spread) { 12 | for (var prop in spread) { 13 | if (_hasOwn.call(spread, prop)) attr(prop, spread[prop]); 14 | } 15 | }; 16 | 17 | var _test$wrapper = function _test$wrapper(_props) { 18 | elementOpenStart("div"); 19 | 20 | _spreadAttribute(_props); 21 | 22 | elementOpenEnd("div"); 23 | return elementClose("div"); 24 | }; 25 | 26 | function render() { 27 | var test = _jsxWrapper(_test$wrapper, [props]); 28 | 29 | elementOpenStart("div"); 30 | 31 | _spreadAttribute(props); 32 | 33 | elementOpenEnd("div"); 34 | return elementClose("div"); 35 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/0/actual.js: -------------------------------------------------------------------------------- 1 | function fn() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/0/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id"]; 2 | 3 | function fn() { 4 | return elementVoid("div", "__uuid__0__", _div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/1/actual.js: -------------------------------------------------------------------------------- 1 | function fn1() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/1/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id"]; 2 | 3 | function fn1() { 4 | return elementVoid("div", "__uuid__0__", _div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/10/actual.js: -------------------------------------------------------------------------------- 1 | function fn7(items) { 2 | return items.map((el, i) => { 3 | return
    ; 4 | }); 5 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/10/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | function fn7(items) { 4 | return items.map(function (el, i) { 5 | _div$statics[3] = i; 6 | return elementVoid("div", i, _div$statics); 7 | }); 8 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/11/actual.js: -------------------------------------------------------------------------------- 1 | function fn7(items) { 2 | items = items.map((el, i) => { 3 | return
    ; 4 | }); 5 | return ; 6 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/11/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$statics = ["id", "id", "key", ""], 10 | _div$wrapper = function _div$wrapper(_i) { 11 | _div$statics[3] = _i; 12 | return elementVoid("div", _i, _div$statics); 13 | }; 14 | 15 | function fn7(items) { 16 | items = items.map(function (el, i) { 17 | return _jsxWrapper(_div$wrapper, [i]); 18 | }); 19 | return elementVoid("root"); 20 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/12/actual.js: -------------------------------------------------------------------------------- 1 | function fn7(items) { 2 | var els = []; 3 | for (var i = 0; i < items.length; i++) { 4 | els.push(
    ); 5 | } 6 | return els; 7 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/12/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$statics = ["id", "id"], 10 | _div$wrapper = function _div$wrapper() { 11 | return elementVoid("div", "__uuid__0__", _div$statics); 12 | }; 13 | 14 | function fn7(items) { 15 | var els = []; 16 | 17 | for (var i = 0; i < items.length; i++) { 18 | els.push(_jsxWrapper(_div$wrapper)); 19 | } 20 | 21 | return els; 22 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/13/actual.js: -------------------------------------------------------------------------------- 1 | function fn7(items) { 2 | return items.map((el, i) => { 3 | return
    ; 4 | }); 5 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/13/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id"]; 2 | 3 | function fn7(items) { 4 | return items.map(function (el, i) { 5 | return elementVoid("div", "__uuid__0__", _div$statics); 6 | }); 7 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/14/actual.js: -------------------------------------------------------------------------------- 1 | function fn7(items) { 2 | items = items.map((el, i) => { 3 | return
    ; 4 | }); 5 | return ; 6 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/14/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$statics = ["id", "id"], 10 | _div$wrapper = function _div$wrapper() { 11 | return elementVoid("div", "__uuid__0__", _div$statics); 12 | }; 13 | 14 | function fn7(items) { 15 | items = items.map(function (el, i) { 16 | return _jsxWrapper(_div$wrapper); 17 | }); 18 | return elementVoid("root"); 19 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/15/actual.js: -------------------------------------------------------------------------------- 1 | function fn7(items) { 2 | var els = []; 3 | for (var i = 0; i < items.length; i++) { 4 | els.push(
    ); 5 | } 6 | return els; 7 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/15/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$statics = ["id", "id", "key", "key"], 10 | _div$wrapper = function _div$wrapper() { 11 | return elementVoid("div", "key", _div$statics); 12 | }; 13 | 14 | function fn7(items) { 15 | var els = []; 16 | 17 | for (var i = 0; i < items.length; i++) { 18 | els.push(_jsxWrapper(_div$wrapper)); 19 | } 20 | 21 | return els; 22 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/16/actual.js: -------------------------------------------------------------------------------- 1 | function fn8() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/16/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id2"], 2 | _div$statics2 = ["id", "id"]; 3 | 4 | function fn8() { 5 | elementOpen("div", "__uuid__0__", _div$statics2); 6 | elementVoid("div", "__uuid__1__", _div$statics); 7 | return elementClose("div"); 8 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/17/actual.js: -------------------------------------------------------------------------------- 1 | function fn8() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/17/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id2", "key", ""], 2 | _div$statics2 = ["id", "id"]; 3 | 4 | function fn8() { 5 | elementOpen("div", "__uuid__0__", _div$statics2); 6 | _div$statics[3] = key4; 7 | elementVoid("div", key4, _div$statics); 8 | return elementClose("div"); 9 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/18/actual.js: -------------------------------------------------------------------------------- 1 | function fn8(key4) { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/18/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id2", "key", ""], 2 | _div$statics2 = ["id", "id"]; 3 | 4 | function fn8(key4) { 5 | elementOpen("div", "__uuid__0__", _div$statics2); 6 | _div$statics[3] = key4; 7 | elementVoid("div", key4, _div$statics); 8 | return elementClose("div"); 9 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/19/actual.js: -------------------------------------------------------------------------------- 1 | function fn8(key4) { 2 | var a =
    ; 3 | return 4 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/19/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _a$statics = ["id", "id2", "key", ""], 10 | _a$statics2 = ["id", "id"], 11 | _a$wrapper = function _a$wrapper(_key) { 12 | elementOpen("div", "__uuid__0__", _a$statics2); 13 | _a$statics[3] = _key; 14 | elementVoid("div", _key, _a$statics); 15 | return elementClose("div"); 16 | }; 17 | 18 | function fn8(key4) { 19 | var a = _jsxWrapper(_a$wrapper, [key4]); 20 | 21 | return elementVoid("root"); 22 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/2/actual.js: -------------------------------------------------------------------------------- 1 | function fn2() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/2/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "3"]; 2 | 3 | function fn2() { 4 | return elementVoid("div", "__uuid__0__", _div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/20/actual.js: -------------------------------------------------------------------------------- 1 | function test() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/20/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", "test"]; 2 | 3 | function test() { 4 | return elementVoid("div", "test", _div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/21/actual.js: -------------------------------------------------------------------------------- 1 | var test = (key) => (1,
    ); -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/21/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$statics = ["id", "id", "key", ""], 10 | _div$wrapper = function _div$wrapper(_key) { 11 | _div$statics[3] = _key; 12 | return elementVoid("div", _key, _div$statics); 13 | }; 14 | 15 | var test = function test(key) { 16 | return 1, _jsxWrapper(_div$wrapper, [key]); 17 | }; -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/22/actual.js: -------------------------------------------------------------------------------- 1 | function test() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/22/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | function test() { 4 | _div$statics[3] = key; 5 | return elementVoid("div", key, _div$statics); 6 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/23/actual.js: -------------------------------------------------------------------------------- 1 | function test() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/23/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | function test() { 4 | var _div$key; 5 | 6 | _div$key = _div$statics[3] = props.key; 7 | return elementVoid("div", _div$key, _div$statics); 8 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/24/actual.js: -------------------------------------------------------------------------------- 1 | function test(props) { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/24/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | function test(props) { 4 | var _div$key; 5 | 6 | _div$key = _div$statics[3] = props.key; 7 | return elementVoid("div", _div$key, _div$statics); 8 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/25/actual.js: -------------------------------------------------------------------------------- 1 | function test(props) { 2 | props.key = 1; 3 | return
    ; 4 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/25/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | function test(props) { 4 | var _div$key; 5 | 6 | props.key = 1; 7 | _div$key = _div$statics[3] = props.key; 8 | return elementVoid("div", _div$key, _div$statics); 9 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/26/actual.js: -------------------------------------------------------------------------------- 1 | function test(key) { 2 | key = 1; 3 | return
    ; 4 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/26/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | function test(key) { 4 | key = 1; 5 | _div$statics[3] = key; 6 | return elementVoid("div", key, _div$statics); 7 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/27/actual.js: -------------------------------------------------------------------------------- 1 | function test() { 2 | var key = 'test'; 3 | key = 1; 4 | return
    ; 5 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/27/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | function test() { 4 | var key = 'test'; 5 | key = 1; 6 | _div$statics[3] = key; 7 | return elementVoid("div", key, _div$statics); 8 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/28/actual.js: -------------------------------------------------------------------------------- 1 | var test = (key) => (key = 2,
    ); -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/28/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$statics = ["id", "id", "key", ""], 10 | _div$wrapper = function _div$wrapper(_key) { 11 | _div$statics[3] = _key; 12 | return elementVoid("div", _key, _div$statics); 13 | }; 14 | 15 | var test = function test(key) { 16 | return key = 2, _jsxWrapper(_div$wrapper, [key]); 17 | }; -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/29/actual.js: -------------------------------------------------------------------------------- 1 | function fn3o() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/29/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | function fn3o() { 4 | return elementVoid("div", "", _div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/3/actual.js: -------------------------------------------------------------------------------- 1 | function fn3o() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/3/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | function fn3o() { 4 | _div$statics[3] = key4; 5 | return elementVoid("div", key4, _div$statics); 6 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/30/actual.js: -------------------------------------------------------------------------------- 1 | function nest() { 2 | return
    3 |
    4 |
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/30/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""], 2 | _div$statics2 = ["id", "id", "key", ""]; 3 | 4 | function nest() { 5 | _div$statics2[3] = key; 6 | elementOpen("div", key, _div$statics2); 7 | _div$statics[3] = key; 8 | elementVoid("div", key, _div$statics); 9 | return elementClose("div"); 10 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/4/actual.js: -------------------------------------------------------------------------------- 1 | var fn3o = () => { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/4/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | var fn3o = function fn3o() { 4 | _div$statics[3] = key4; 5 | return elementVoid("div", key4, _div$statics); 6 | }; -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/5/actual.js: -------------------------------------------------------------------------------- 1 | var fn3o = () =>
    ; -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/5/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | var fn3o = function fn3o() { 4 | _div$statics[3] = key4; 5 | return elementVoid("div", key4, _div$statics); 6 | }; -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/6/actual.js: -------------------------------------------------------------------------------- 1 | function fn4(key4) { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/6/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "other", "value", "another", "test", "key", ""]; 2 | 3 | function fn4(key4) { 4 | _div$statics[7] = key4; 5 | return elementVoid("div", key4, _div$statics); 6 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/7/actual.js: -------------------------------------------------------------------------------- 1 | var fn5 = (key5) => { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/7/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | var fn5 = function fn5(key5) { 4 | _div$statics[3] = key5; 5 | return elementVoid("div", key5, _div$statics); 6 | }; -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/8/actual.js: -------------------------------------------------------------------------------- 1 | var fn6 = (key6) =>
    ; -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/8/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id", "key", ""]; 2 | 3 | var fn6 = function fn6(key6) { 4 | _div$statics[3] = key6; 5 | return elementVoid("div", key6, _div$statics); 6 | }; -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/9/actual.js: -------------------------------------------------------------------------------- 1 | function fn7(items) { 2 | var els = []; 3 | for (var i = 0; i < items.length; i++) { 4 | els.push(
    ); 5 | } 6 | return els; 7 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/9/expected.js: -------------------------------------------------------------------------------- 1 | var _jsxWrapper = function _jsxWrapper(func, args) { 2 | return { 3 | __jsxDOMWrapper: true, 4 | func: func, 5 | args: args 6 | }; 7 | }; 8 | 9 | var _div$statics = ["id", "id", "key", ""], 10 | _div$wrapper = function _div$wrapper(_i) { 11 | _div$statics[3] = _i; 12 | return elementVoid("div", _i, _div$statics); 13 | }; 14 | 15 | function fn7(items) { 16 | var els = []; 17 | 18 | for (var i = 0; i < items.length; i++) { 19 | els.push(_jsxWrapper(_div$wrapper, [i])); 20 | } 21 | 22 | return els; 23 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/key-expression/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/key-expression/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["key", ""]; 2 | 3 | function render() { 4 | var _div$key; 5 | 6 | _div$key = _div$statics[1] = i++; 7 | return elementVoid("div", _div$key, _div$statics); 8 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/key-expression/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "hoist": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/keyless-statics/actual.js: -------------------------------------------------------------------------------- 1 | function fn() { 2 | return
    ; 3 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/keyless-statics/expected.js: -------------------------------------------------------------------------------- 1 | var _div$statics = ["id", "id"]; 2 | 3 | function fn() { 4 | return elementVoid("div", "__uuid__0__", _div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/member-tag-name/actual.js: -------------------------------------------------------------------------------- 1 | function fn() { 2 | return ; 3 | } 4 | -------------------------------------------------------------------------------- /test/fixtures/statics-hoist/member-tag-name/expected.js: -------------------------------------------------------------------------------- 1 | var _a$b$div$statics = ["id", "id"]; 2 | 3 | function fn() { 4 | return elementVoid(a.b.div, "__uuid__0__", _a$b$div$statics); 5 | } -------------------------------------------------------------------------------- /test/fixtures/text/child-number-literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | {1.5213343e6} 4 |
    ; 5 | } -------------------------------------------------------------------------------- /test/fixtures/text/child-number-literal/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | text("1521334.3"); 4 | return elementClose("div"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/text/child-string-element-array/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    {["First ", ·, " Second"]}
    4 |
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/text/child-string-literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    {"First · Second"}
    4 |
    ; 5 | } -------------------------------------------------------------------------------- /test/fixtures/text/child-string-literal/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | elementOpen("div"); 4 | text("First · Second"); 5 | elementClose("div"); 6 | return elementClose("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/text/child-template-literal/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | {`${i}`} 4 | {`text ${i}`} 5 | {`${i} text`} 6 | {`text ${i} text`} 7 | {"text" - i} 8 |
    ; 9 | } 10 | -------------------------------------------------------------------------------- /test/fixtures/text/child-template-literal/expected.js: -------------------------------------------------------------------------------- 1 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 2 | 3 | var _hasOwn = Object.prototype.hasOwnProperty; 4 | 5 | var _renderArbitrary = function _renderArbitrary(child) { 6 | var type = _typeof(child); 7 | 8 | if (type === "number" || type === "string" || type === "object" && child instanceof String) { 9 | text(child); 10 | } else if (Array.isArray(child)) { 11 | for (var i = 0; i < child.length; i++) { 12 | _renderArbitrary(child[i]); 13 | } 14 | } else if (type === "object") { 15 | if (child.__jsxDOMWrapper) { 16 | var func = child.func, 17 | args = child.args; 18 | 19 | if (args) { 20 | func.apply(this, args); 21 | } else { 22 | func(); 23 | } 24 | } else if (String(child) === "[object Object]") { 25 | for (var prop in child) { 26 | if (_hasOwn.call(child, i)) _renderArbitrary(child[i]); 27 | } 28 | } 29 | } 30 | }; 31 | 32 | function render() { 33 | elementOpen("div"); 34 | 35 | _renderArbitrary("".concat(i)); 36 | 37 | _renderArbitrary("text ".concat(i)); 38 | 39 | _renderArbitrary("".concat(i, " text")); 40 | 41 | _renderArbitrary("text ".concat(i, " text")); 42 | 43 | _renderArbitrary("text" - i); 44 | 45 | return elementClose("div"); 46 | } -------------------------------------------------------------------------------- /test/fixtures/text/child/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | Hello World! 4 |
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/text/child/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | text(" Hello World! "); 4 | return elementClose("div"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/text/nested-child/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 |
    Hiya!
    4 |
    ; 5 | } -------------------------------------------------------------------------------- /test/fixtures/text/nested-child/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("div"); 3 | elementOpen("div"); 4 | text("Hiya!"); 5 | elementClose("div"); 6 | return elementClose("div"); 7 | } -------------------------------------------------------------------------------- /test/fixtures/text/pre/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    {`
    3 |     Hello World!
    4 |   `}
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/text/pre/expected.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | elementOpen("pre"); 3 | text("\n Hello World!\n "); 4 | return elementClose("pre"); 5 | } -------------------------------------------------------------------------------- /test/fixtures/uuid-prefix/actual.js: -------------------------------------------------------------------------------- 1 | function render() { 2 | return
    3 | test 4 |
    ; 5 | } 6 | -------------------------------------------------------------------------------- /test/fixtures/uuid-prefix/expected.js: -------------------------------------------------------------------------------- 1 | var _span$statics = ["key", "123", "class", "test"], 2 | _a$statics = ["href", "/test"], 3 | _div$statics = ["id", "test"]; 4 | 5 | function render() { 6 | elementOpen("div", "uuid-2", _div$statics); 7 | elementOpen("a", "uuid-1", _a$statics); 8 | elementOpen("span", "123", _span$statics); 9 | text("test"); 10 | elementClose("span"); 11 | elementClose("a"); 12 | return elementClose("div"); 13 | } -------------------------------------------------------------------------------- /test/fixtures/uuid-prefix/options.json: -------------------------------------------------------------------------------- 1 | { 2 | "options": { 3 | "uuidPrefix": "uuid-" 4 | } 5 | } 6 | --------------------------------------------------------------------------------