From 600e6255be5c3a7f391eb48ac7995bf39f13b819 Mon Sep 17 00:00:00 2001
From: 07akioni <07akioni2@gmail.com>
Date: Sun, 26 Dec 2021 03:52:14 +0800
Subject: [PATCH] fix(code): content is repeatly appended if language is not
set, closes #2034
---
CHANGELOG.en-US.md | 1 +
CHANGELOG.zh-CN.md | 1 +
src/code/demos/zhCN/index.demo-entry.md | 1 +
src/code/demos/zhCN/loop-debug.demo.vue | 27 +++++++++++++++++++++++++
src/code/src/Code.tsx | 1 +
5 files changed, 31 insertions(+)
create mode 100644 src/code/demos/zhCN/loop-debug.demo.vue
diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md
index c70c5981055..bf1b9eec101 100644
--- a/CHANGELOG.en-US.md
+++ b/CHANGELOG.en-US.md
@@ -62,6 +62,7 @@
- Fix `n-form-item-gi` 's `validate` doesn't work, closes [#1901](https://github.com/TuSimple/naive-ui/issues/1901).
- Fix `n-card` action's border-radius style.
+- Fix `n-code`'s content is repeatly appended if language is not set, closes [#2034](https://github.com/TuSimple/naive-ui/issues/2034).
## 2.23.1 (2021-12-20)
diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md
index 15844d571ba..e63c8622778 100644
--- a/CHANGELOG.zh-CN.md
+++ b/CHANGELOG.zh-CN.md
@@ -62,6 +62,7 @@
- 修复 `n-form-item-gi` 的 `validate` 不生效,关闭 [#1901](https://github.com/TuSimple/naive-ui/issues/1901)
- 修复 `n-card` action 部分的 border-radius 样式
+- 修复 `n-code` 不设定 language 时内容重复添加,关闭 [#2034](https://github.com/TuSimple/naive-ui/issues/2034)
## 2.23.1 (2021-12-20)
diff --git a/src/code/demos/zhCN/index.demo-entry.md b/src/code/demos/zhCN/index.demo-entry.md
index 918422ae99b..768a2dda613 100644
--- a/src/code/demos/zhCN/index.demo-entry.md
+++ b/src/code/demos/zhCN/index.demo-entry.md
@@ -37,6 +37,7 @@
```demo
basic.vue
inline.vue
+loop-debug.vue
```
## API
diff --git a/src/code/demos/zhCN/loop-debug.demo.vue b/src/code/demos/zhCN/loop-debug.demo.vue
new file mode 100644
index 00000000000..36542df7da8
--- /dev/null
+++ b/src/code/demos/zhCN/loop-debug.demo.vue
@@ -0,0 +1,27 @@
+
+# Loop debug
+
+
+
+
+
+
+
diff --git a/src/code/src/Code.tsx b/src/code/src/Code.tsx
index 47fadc11f3a..7713c063c29 100644
--- a/src/code/src/Code.tsx
+++ b/src/code/src/Code.tsx
@@ -82,6 +82,7 @@ export default defineComponent({
}
const warp = document.createElement('pre')
warp.textContent = code
+ codeEl.innerHTML = ''
codeEl.appendChild(warp)
}
onMounted(setCode)