Skip to content

Commit 0c3a0b7

Browse files
committed
fix missing / in CodeSnippet
1 parent 7d77866 commit 0c3a0b7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/components/right-sidebar/CodeSnippet.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ export default {
109109
h5: ["<h5", "</h5>"],
110110
h6: ["<h6", "</h6>"],
111111
};
112-
this.componentMap[this.activeComponent].children.forEach(child => {
112+
//add childComponents of the activeCompnent to the htmlElementMap
113+
const childComponents = this.componentMap[this.activeComponent].children;
114+
childComponents.forEach(child => {
113115
htmlElementMap[child]=[`<${child}`, ""] //single
114116
})
115117
function writeNested(childrenArray, indent) {
@@ -128,7 +130,7 @@ export default {
128130
if (child.class !== "") {
129131
nestedString += " " + "class = " + `"${child.class}"`;
130132
}
131-
if (child.text === "img" || child.text === "input" || child.text === "link") {
133+
if (child.text === "img" || child.text === "input" || child.text === "link" || childComponents.includes(child.text)) {
132134
nestedString += "/>";
133135
} else { nestedString += ">"; }
134136
@@ -159,8 +161,8 @@ export default {
159161
if (el.class !== "") {
160162
outputStr += " " + "class = " + `"${el.class}"`;
161163
}
162-
// add an extra slash at the end for child Components
163-
if(this.componentMap[this.activeComponent].children.includes(el.text)){
164+
// add an extra slash at the end for child Components and single tags
165+
if(childComponents.includes(el.text) || el.text === "img" || el.text === "input" || el.text === "link"){
164166
outputStr += "/"
165167
}
166168

0 commit comments

Comments
 (0)