diff --git a/examples/src/main.js b/examples/src/main.js index b45ffd1..4f6292e 100644 --- a/examples/src/main.js +++ b/examples/src/main.js @@ -16,7 +16,7 @@ class TestComponent extends Component {
this.dispatch('update')}>hhhhh
`; diff --git a/main.js b/main.js index 0f9c39a..f5fab9d 100644 --- a/main.js +++ b/main.js @@ -329,16 +329,8 @@ class Template extends RenderPart { for(const i in this.placeholder){ const placeholder = this.placeholder[i]; const {type, hash} = placeholder; - while(walker.nextNode()){ - if(walker.currentNode instanceof Text) continue; - if(walker.currentNode instanceof Comment && walker.currentNode.data.trim() == 'node-'+hash+'-start'){ - break; - }else if(type == 'attr' && walker.currentNode instanceof HTMLElement && walker.currentNode.hasAttribute('data-attr'+hash)) { - break; - } - } if(type == 'attr'){ - const element = walker.currentNode; + const element = this.fragment.querySelector('[data-attr'+hash+']'); const a = placeholder.attr; switch(a[0]) { case "@": @@ -360,7 +352,12 @@ class Template extends RenderPart { break; } }else{ - walker.nextNode(); + do{ + if(walker.currentNode instanceof Text) continue; + if(walker.currentNode instanceof Comment && walker.currentNode.data.trim() == 'node-'+hash+'-start'){ + break; + } + } while(walker.nextNode()); const range = document.createRange(); let current = walker.currentNode; let container = current.parentNode ? current.parentNode : this.fragment; diff --git a/webpack.config.js b/webpack.config.js index 3786124..db6619c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,3 @@ -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); - module.exports = { mode: 'production', entry: './main.js',