Skip to content

Commit 069342b

Browse files
committed
fix: data-ld-highlight attribute leaks in the source code
1 parent de6ee39 commit 069342b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/LiveDevelopment/LivePreviewEdit.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ define(function (require, exports, module) {
4141
// this function is to remove the phoenix internal attributes from leaking into the user's source code
4242
function cleanClonedElement(clonedElement) {
4343
if (clonedElement.nodeType === Node.ELEMENT_NODE) {
44-
clonedElement.removeAttribute("data-brackets-id");
44+
// this are phoenix's internal attributes
45+
const attrs = ["data-brackets-id", "data-ld-highlight"];
4546

46-
const children = clonedElement.querySelectorAll("[data-brackets-id]");
47-
children.forEach(child => child.removeAttribute("data-brackets-id"));
47+
// remove from the cloned element
48+
attrs.forEach(attr => clonedElement.removeAttribute(attr));
49+
50+
// also remove from its childrens
51+
clonedElement.querySelectorAll(attrs.map(a => `[${a}]`).join(","))
52+
.forEach(el => attrs.forEach(attr => el.removeAttribute(attr)));
4853
}
4954
return clonedElement;
5055
}

0 commit comments

Comments
 (0)