diff --git a/src/generators/dom/Fragment.js b/src/generators/dom/Fragment.js index 490b16c845..b32b12e69b 100644 --- a/src/generators/dom/Fragment.js +++ b/src/generators/dom/Fragment.js @@ -1,5 +1,7 @@ +import CodeBuilder from '../../utils/CodeBuilder.js'; + export default class Fragment { - constructor ({ generator, name, key, expression, context, contextDependencies, component, contexts, indexes, params, indexNames, listNames, builders, getUniqueName }) { + constructor ({ generator, name, key, expression, context, contextDependencies, component, contexts, indexes, params, indexNames, listNames, getUniqueName }) { this.generator = generator; this.name = name; this.key = key; @@ -16,7 +18,14 @@ export default class Fragment { this.indexNames = indexNames; this.listNames = listNames; - this.builders = builders; + this.builders = { + create: new CodeBuilder(), + mount: new CodeBuilder(), + update: new CodeBuilder(), + detach: new CodeBuilder(), + detachRaw: new CodeBuilder(), + destroy: new CodeBuilder() + }; this.getUniqueName = getUniqueName; } diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index 4d11107f44..a9506599e7 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -1,5 +1,4 @@ import deindent from '../../utils/deindent.js'; -import getBuilders from './utils/getBuilders.js'; import CodeBuilder from '../../utils/CodeBuilder.js'; import visit from './visit.js'; import Generator from '../Generator.js'; @@ -122,7 +121,6 @@ export default function dom ( parsed, source, options ) { indexNames: new Map(), listNames: new Map(), - builders: getBuilders(), getUniqueName }); diff --git a/src/generators/dom/utils/getBuilders.js b/src/generators/dom/utils/getBuilders.js deleted file mode 100644 index 396ab54aa6..0000000000 --- a/src/generators/dom/utils/getBuilders.js +++ /dev/null @@ -1,12 +0,0 @@ -import CodeBuilder from '../../../utils/CodeBuilder.js'; - -export default function getBuilders () { - return { - create: new CodeBuilder(), - mount: new CodeBuilder(), - update: new CodeBuilder(), - detach: new CodeBuilder(), - detachRaw: new CodeBuilder(), - destroy: new CodeBuilder() - }; -} diff --git a/src/generators/dom/visitors/Component.js b/src/generators/dom/visitors/Component.js index 56f9468ca4..27d13c1d9e 100644 --- a/src/generators/dom/visitors/Component.js +++ b/src/generators/dom/visitors/Component.js @@ -1,6 +1,5 @@ import deindent from '../../../utils/deindent.js'; import CodeBuilder from '../../../utils/CodeBuilder.js'; -import getBuilders from '../utils/getBuilders.js'; import visit from '../visit.js'; import addComponentAttributes from './attributes/addComponentAttributes.js'; @@ -79,8 +78,7 @@ export default function visitComponent ( generator, fragment, state, node ) { const params = fragment.params.join( ', ' ); const childFragment = fragment.child({ - name: generator.getUniqueName( `render_${name}_yield_fragment` ), // TODO should getUniqueName happen inside Fragment? probably - builders: getBuilders() + name: generator.getUniqueName( `render_${name}_yield_fragment` ) // TODO should getUniqueName happen inside Fragment? probably }); const childState = Object.assign( {}, state, { diff --git a/src/generators/dom/visitors/EachBlock.js b/src/generators/dom/visitors/EachBlock.js index 662e7e6672..1985ee780b 100644 --- a/src/generators/dom/visitors/EachBlock.js +++ b/src/generators/dom/visitors/EachBlock.js @@ -1,6 +1,5 @@ import CodeBuilder from '../../../utils/CodeBuilder.js'; import deindent from '../../../utils/deindent.js'; -import getBuilders from '../utils/getBuilders.js'; import visit from '../visit.js'; export default function visitEachBlock ( generator, fragment, state, node ) { @@ -204,7 +203,6 @@ export default function visitEachBlock ( generator, fragment, state, node ) { listNames, params: blockParams, - builders: getBuilders(), getUniqueName }); @@ -221,7 +219,6 @@ export default function visitEachBlock ( generator, fragment, state, node ) { if ( node.else ) { const childFragment = fragment.child({ name: renderElse, - builders: getBuilders(), getUniqueName: generator.getUniqueNameMaker( fragment.params ) }); diff --git a/src/generators/dom/visitors/IfBlock.js b/src/generators/dom/visitors/IfBlock.js index f94de000d4..e24215f69a 100644 --- a/src/generators/dom/visitors/IfBlock.js +++ b/src/generators/dom/visitors/IfBlock.js @@ -1,5 +1,4 @@ import deindent from '../../../utils/deindent.js'; -import getBuilders from '../utils/getBuilders.js'; import visit from '../visit.js'; function getConditionsAndBlocks ( generator, fragment, state, node, _name, i = 0 ) { @@ -34,8 +33,7 @@ function getConditionsAndBlocks ( generator, fragment, state, node, _name, i = 0 function generateBlock ( generator, fragment, state, node, name ) { const childFragment = fragment.child({ - name, - builders: getBuilders() + name }); const childState = Object.assign( {}, state, {