@@ -38,6 +38,17 @@ define(function (require, exports, module) {
3838 const oldRoot = oldDoc . body ;
3939 const newRoot = newDoc . body ;
4040
41+ // this function is to remove the phoenix internal attributes from leaking into the user's source code
42+ function cleanClonedElement ( clonedElement ) {
43+ if ( clonedElement . nodeType === Node . ELEMENT_NODE ) {
44+ clonedElement . removeAttribute ( "data-brackets-id" ) ;
45+
46+ const children = clonedElement . querySelectorAll ( "[data-brackets-id]" ) ;
47+ children . forEach ( child => child . removeAttribute ( "data-brackets-id" ) ) ;
48+ }
49+ return clonedElement ;
50+ }
51+
4152 function syncText ( oldNode , newNode ) {
4253 if ( ! oldNode || ! newNode ) {
4354 return ;
@@ -64,7 +75,8 @@ define(function (require, exports, module) {
6475
6576 if ( ! oldChild && newChild ) {
6677 // if new child added → clone and insert
67- oldNode . appendChild ( newChild . cloneNode ( true ) ) ;
78+ const cloned = newChild . cloneNode ( true ) ;
79+ oldNode . appendChild ( cleanClonedElement ( cloned ) ) ;
6880 } else if ( oldChild && ! newChild ) {
6981 // if child removed → delete
7082 oldNode . removeChild ( oldChild ) ;
@@ -84,7 +96,8 @@ define(function (require, exports, module) {
8496 }
8597 } else {
8698 // different node types or tags → replace
87- oldNode . replaceChild ( newChild . cloneNode ( true ) , oldChild ) ;
99+ const cloned = newChild . cloneNode ( true ) ;
100+ oldNode . replaceChild ( cleanClonedElement ( cloned ) , oldChild ) ;
88101 }
89102 }
90103 }
0 commit comments