Skip to content

Commit

Permalink
fix(code): content is repeatly appended if language is not set, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
07akioni committed Dec 25, 2021
1 parent 63f78d6 commit 600e625
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions src/code/demos/zhCN/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
```demo
basic.vue
inline.vue
loop-debug.vue
```

## API
Expand Down
27 changes: 27 additions & 0 deletions src/code/demos/zhCN/loop-debug.demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<markdown>
# Loop debug
</markdown>

<template>
<n-code :code="code" />
</template>

<script lang="ts">
import { defineComponent, ref, onBeforeUnmount } from 'vue'
export default defineComponent({
setup () {
const code = ref('')
const id = setInterval(() => {
code.value = 'Current: ' + String(new Date())
}, 1000)
onBeforeUnmount(() => {
clearInterval(id)
})
return { code }
}
})
</script>
1 change: 1 addition & 0 deletions src/code/src/Code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default defineComponent({
}
const warp = document.createElement('pre')
warp.textContent = code
codeEl.innerHTML = ''
codeEl.appendChild(warp)
}
onMounted(setCode)
Expand Down

0 comments on commit 600e625

Please sign in to comment.