@@ -5,10 +5,11 @@ import {
55 ATTRIBUTE as TEMPLATE_ATTRIBUTE ,
66 COMMENT as TEMPLATE_COMMENT ,
77 COMPONENT as TEMPLATE_COMPONENT ,
8+ DATA as TEMPLATE_DATA ,
89 TEXT as TEMPLATE_TEXT ,
910} from './ish.js' ;
1011
11- import { Unsafe , assign , entries , isArray } from '../utils.js' ;
12+ import { Unsafe , assign , entries , reduce , isArray } from '../utils.js' ;
1213import { PersistentFragment , diffFragment } from './persistent-fragment.js' ;
1314import { ref } from './ref.js' ;
1415import creator from './creator.js' ;
@@ -167,6 +168,7 @@ export const update = (node, type, path, name, hint) => {
167168 }
168169 }
169170 }
171+ case TEMPLATE_DATA : return pdt ( path , directFor ( 'data' ) , TEXT ) ;
170172 }
171173} ;
172174
@@ -211,8 +213,10 @@ function toggle(node, curr) {
211213
212214function unsafe ( node , curr ) {
213215 const [ wm , xml ] = this ;
214- const pf = PersistentFragment ( fragment ( curr , xml ) ) ;
215- ( wm . get ( node ) ?? node ) . replaceWith ( pf ) ;
216- wm . set ( node , pf ) ;
216+ const f = fragment ( curr , xml ) ;
217+ const u = reduce ( f ) ;
218+ const n = u === f ? PersistentFragment ( u ) : u ;
219+ ( wm . get ( node ) ?? node ) . replaceWith ( n ) ;
220+ wm . set ( node , n ) ;
217221 return curr ;
218222}
0 commit comments