Skip to content

Commit

Permalink
[update]
Browse files Browse the repository at this point in the history
  • Loading branch information
木瓜丸 committed Dec 8, 2020
1 parent 82afde2 commit 80e4ff7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
14 changes: 12 additions & 2 deletions examples/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,25 @@ class TestComponent extends Component {
<div id='he' @click=${e => this.dispatch('update')}>hhhhh</div>
<ul>
${state.arr.map((_, i) => html`
<li>${
<li class=${
i%15 == 0
?'fizzbuzz'
: i%5 == 0
? 'buzz'
: i%3 == 0
? 'fizz'
: i
}</li>
} data-id=${i%2==0?'even':'odd'}>
${
i%15 == 0
?'fizzbuzz'
: i%5 == 0
? 'buzz'
: i%3 == 0
? 'fizz'
: i
}
</li>
`)}
</ul>
`;
Expand Down
17 changes: 7 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 "@":
Expand All @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
mode: 'production',
entry: './main.js',
Expand Down

0 comments on commit 80e4ff7

Please sign in to comment.