From 02c7a75ee3d7725157b744bb710bd879f01a0065 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Mon, 14 Sep 2020 15:42:04 +0800 Subject: [PATCH] breaking change: disable allow-html by default --- docs/markdown/migrate-from-v2.zh-CN.md | 2 ++ src/dialog/Dialog.js | 5 +---- src/dialog/README.md | 4 ++-- src/dialog/README.zh-CN.md | 4 ++-- src/dialog/index.js | 2 +- src/picker/README.md | 2 +- src/picker/README.zh-CN.md | 2 +- src/picker/shared.ts | 5 +---- 8 files changed, 11 insertions(+), 15 deletions(-) diff --git a/docs/markdown/migrate-from-v2.zh-CN.md b/docs/markdown/migrate-from-v2.zh-CN.md index 6e49a748a..47081d140 100644 --- a/docs/markdown/migrate-from-v2.zh-CN.md +++ b/docs/markdown/migrate-from-v2.zh-CN.md @@ -174,6 +174,7 @@ Vue 3.0 中增加了 `Teleport` 组件,提供将组件渲染到任意 DOM 位 #### Dialog +- 默认关闭 `allow-html` 属性 - `before-close` 属性用法调整,不再传入 done 函数,而是通过返回 Promise 来控制 #### ImagePreview @@ -183,6 +184,7 @@ Vue 3.0 中增加了 `Teleport` 组件,提供将组件渲染到任意 DOM 位 #### Picker - `change` 事件参数不再传入组件实例 +- 默认关闭 `allow-html` 属性 - 默认开启 `show-toolbar` 属性 - 级联选择下,`confirm`、`change` 事件返回的回调参数将包含为完整的选项对象。 diff --git a/src/dialog/Dialog.js b/src/dialog/Dialog.js index d54f9f817..3104ad152 100644 --- a/src/dialog/Dialog.js +++ b/src/dialog/Dialog.js @@ -27,6 +27,7 @@ export default createComponent({ width: [Number, String], message: String, callback: Function, + allowHtml: Boolean, className: null, beforeClose: Function, messageAlign: String, @@ -36,10 +37,6 @@ export default createComponent({ confirmButtonText: String, confirmButtonColor: String, closeOnClickOverlay: Boolean, - allowHtml: { - type: Boolean, - default: true, - }, transition: { type: String, default: 'van-dialog-bounce', diff --git a/src/dialog/README.md b/src/dialog/README.md index 26aa5b11e..18d5ba6a1 100644 --- a/src/dialog/README.md +++ b/src/dialog/README.md @@ -155,7 +155,7 @@ export default { | closeOnPopstate | Whether to close when popstate | _boolean_ | `true` | | closeOnClickOverlay | Whether to close when click overlay | _boolean_ | `false` | | lockScroll | Whether to lock body scroll | _boolean_ | `true` | -| allowHtml `v2.8.7` | Whether to allow HTML rendering in message | _boolean_ | `true` | +| allowHtml `v2.8.7` | Whether to allow HTML rendering in message | _boolean_ | `false` | | beforeClose | Callback function before close,
call done() to close dialog,
call done(false) to cancel loading | (action: string, done: Function) => void | - | | transition | Transition, equivalent to `name` prop of [transtion](https://vuejs.org/v2/api/#transition) | _string_ | - | | teleport | Return the mount node for Dialog | _string \| Element_ | `body` | @@ -183,7 +183,7 @@ export default { | close-on-click-overlay | Whether to close when click overlay | _boolean_ | `false` | | lazy-render | Whether to lazy render util appeared | _boolean_ | `true` | | lock-scroll | Whether to lock background scroll | _boolean_ | `true` | -| allow-html `v2.8.7` | Whether to allow HTML rendering in message | _boolean_ | `true` | +| allow-html `v2.8.7` | Whether to allow HTML rendering in message | _boolean_ | `false` | | before-close | Callback function before close | _(action) => boolean \| Promise_ | - | | transition | Transition, equivalent to `name` prop of [transtion](https://vuejs.org/v2/api/#transition) | _string_ | - | | teleport | Return the mount node for Dialog | _string \| Element_ | - | diff --git a/src/dialog/README.zh-CN.md b/src/dialog/README.zh-CN.md index 6a4e594c7..1d2f1540e 100644 --- a/src/dialog/README.zh-CN.md +++ b/src/dialog/README.zh-CN.md @@ -190,7 +190,7 @@ export default { | closeOnPopstate | 是否在页面回退时自动关闭 | _boolean_ | `true` | | closeOnClickOverlay | 是否在点击遮罩层后关闭弹窗 | _boolean_ | `false` | | lockScroll | 是否锁定背景滚动 | _boolean_ | `true` | -| allowHtml `v2.8.7` | 是否允许 message 内容中渲染 HTML | _boolean_ | `true` | +| allowHtml `v2.8.7` | 是否允许 message 内容中渲染 HTML | _boolean_ | `false` | | beforeClose | 关闭前的回调函数,
调用 done() 后关闭弹窗,
调用 done(false) 阻止弹窗关闭 | _(action, done) => void_ | - | | transition | 动画类名,等价于 [transtion](https://cn.vuejs.org/v2/api/index.html#transition) 的`name`属性 | _string_ | - | | teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | `body` | @@ -220,7 +220,7 @@ export default { | close-on-click-overlay | 是否在点击遮罩层后关闭弹窗 | _boolean_ | `false` | | lazy-render | 是否在显示弹层时才渲染节点 | _boolean_ | `true` | | lock-scroll | 是否锁定背景滚动 | _boolean_ | `true` | -| allow-html `v2.8.7` | 是否允许 message 内容中渲染 HTML | _boolean_ | `true` | +| allow-html `v2.8.7` | 是否允许 message 内容中渲染 HTML | _boolean_ | `false` | | before-close | 关闭前的回调函数,返回 `false` 可阻止关闭,支持返回 Promise | _(action) => boolean \| Promise_ | - | | transition | 动画类名,等价于 [transtion](https://cn.vuejs.org/v2/api/index.html#transition) 的`name`属性 | _string_ | - | | teleport | 指定挂载的节点,[用法示例](#/zh-CN/popup#zhi-ding-gua-zai-wei-zhi) | _string \| Element_ | - | diff --git a/src/dialog/index.js b/src/dialog/index.js index 9631bdf5d..dbe8350c0 100644 --- a/src/dialog/index.js +++ b/src/dialog/index.js @@ -45,7 +45,7 @@ Dialog.defaultOptions = { callback: null, teleport: 'body', className: '', - allowHtml: true, + allowHtml: false, lockScroll: true, transition: 'van-dialog-bounce', beforeClose: null, diff --git a/src/picker/README.md b/src/picker/README.md index ed1b29bc9..8bc98736f 100644 --- a/src/picker/README.md +++ b/src/picker/README.md @@ -249,7 +249,7 @@ export default { | toolbar-position | Toolbar position, cat be set to `bottom` | _string_ | `top` | | loading | Whether to show loading prompt | _boolean_ | `false` | | show-toolbar | Whether to show toolbar | _boolean_ | `true` | -| allow-html | Whether to allow HTML in option text | _boolean_ | `true` | +| allow-html | Whether to allow HTML in option text | _boolean_ | `false` | | default-index | Default value index of single column picker | _number \| string_ | `0` | | item-height `v2.8.6` | Option height, supports `px` `vw` `rem` unit, default `px` | _number \| string_ | `44` | | visible-item-count | Count of visible columns | _number \| string_ | `6` | diff --git a/src/picker/README.zh-CN.md b/src/picker/README.zh-CN.md index b75a409a7..efa63a6b3 100644 --- a/src/picker/README.zh-CN.md +++ b/src/picker/README.zh-CN.md @@ -272,7 +272,7 @@ export default { | toolbar-position | 顶部栏位置,可选值为`bottom` | _string_ | `top` | | loading | 是否显示加载状态 | _boolean_ | `false` | | show-toolbar | 是否显示顶部栏 | _boolean_ | `true` | -| allow-html | 是否允许选项内容中渲染 HTML | _boolean_ | `true` | +| allow-html | 是否允许选项内容中渲染 HTML | _boolean_ | `false` | | default-index | 单列选择时,默认选中项的索引 | _number \| string_ | `0` | | item-height `v2.8.6` | 选项高度,支持 `px` `vw` `rem` 单位,默认 `px` | _number \| string_ | `44` | | visible-item-count | 可见的选项个数 | _number \| string_ | `6` | diff --git a/src/picker/shared.ts b/src/picker/shared.ts index 7f0c64a5b..0a59b3dfe 100644 --- a/src/picker/shared.ts +++ b/src/picker/shared.ts @@ -14,6 +14,7 @@ export const pickerProps = { title: String, loading: Boolean, readonly: Boolean, + allowHtml: Boolean, itemHeight: [Number, String], cancelButtonText: String, confirmButtonText: String, @@ -21,10 +22,6 @@ export const pickerProps = { type: Boolean, default: true, }, - allowHtml: { - type: Boolean, - default: true, - }, visibleItemCount: { type: [Number, String], default: 6,