提交 e408d001 编写于 作者: Q qiang

fix: 修复部分组件嵌套在 uni-popup 组件内渲染错误的问题

上级 e8ddbb9f
<script>
import {
disableScrollBounce
disableScrollBounce,
deepClone
} from 'uni-shared'
function calc (e) {
......@@ -56,9 +57,9 @@ export default {
}
return get(target)
},
_touchstart (t) {
disableScrollBounce({
disable: true
_touchstart (t) {
disableScrollBounce({
disable: true
})
var i = t.touches
if (i) {
......@@ -94,9 +95,9 @@ export default {
}
}
},
_touchend (e) {
disableScrollBounce({
disable: false
_touchend (e) {
disableScrollBounce({
disable: false
})
var t = e.touches
if (!(t && t.length)) {
......@@ -142,8 +143,9 @@ export default {
},
render (createElement) {
var items = []
if (this.$slots.default) {
this.$slots.default.forEach(vnode => {
const $slots = this.$slots.default && deepClone(this.$slots.default, createElement)
if ($slots) {
$slots.forEach(vnode => {
if (vnode.componentOptions && vnode.componentOptions.tag === 'v-uni-movable-view') {
items.push(vnode)
}
......@@ -163,7 +165,7 @@ export default {
on: {
resize: this._resize
}
}), this.$slots.default])
}), $slots])
}
}
</script>
......@@ -178,4 +180,4 @@ export default {
uni-movable-area[hidden] {
display: none;
}
</style>
</style>
<script>
import { deepClone } from 'uni-shared'
export default {
name: 'PickerView',
props: {
......@@ -93,7 +95,7 @@ export default {
render (createElement) {
var items = []
if (this.$slots.default) {
this.$slots.default.forEach(vnode => {
deepClone(this.$slots.default, createElement).forEach(vnode => {
if (vnode.componentOptions && vnode.componentOptions.tag === 'v-uni-picker-view-column') {
items.push(vnode)
}
......
<script>
import touchtrack from 'uni-mixins/touchtrack'
function deepClone (vnodes, createElement) {
function cloneVNode (vnode) {
var clonedChildren = vnode.children && vnode.children.map(cloneVNode)
var cloned = createElement(vnode.tag, vnode.data, clonedChildren)
cloned.text = vnode.text
cloned.isComment = vnode.isComment
cloned.componentOptions = vnode.componentOptions
cloned.elm = vnode.elm
cloned.context = vnode.context
cloned.ns = vnode.ns
cloned.isStatic = vnode.isStatic
cloned.key = vnode.key
return cloned
}
return vnodes.map(cloneVNode)
}
import { deepClone } from 'uni-shared'
export default {
name: 'Swiper',
......
......@@ -95,43 +95,61 @@ export function debounce (fn, delay) {
export function kebabCase (string) {
return string.replace(/[A-Z]/g, str => '-' + str.toLowerCase())
}
/**
* Check if two values are loosely equal - that is,
* if they are plain objects, do they have the same shape?
*/
export function looseEqual (a, b) {
if (a === b) return true
const isObjectA = isObject(a)
const isObjectB = isObject(b)
if (isObjectA && isObjectB) {
try {
const isArrayA = Array.isArray(a)
const isArrayB = Array.isArray(b)
if (isArrayA && isArrayB) {
return a.length === b.length && a.every((e, i) => {
return looseEqual(e, b[i])
})
} else if (a instanceof Date && b instanceof Date) {
return a.getTime() === b.getTime()
} else if (!isArrayA && !isArrayB) {
const keysA = Object.keys(a)
const keysB = Object.keys(b)
return keysA.length === keysB.length && keysA.every(key => {
return looseEqual(a[key], b[key])
})
} else {
/* istanbul ignore next */
return false
}
} catch (e) {
/* istanbul ignore next */
return false
}
} else if (!isObjectA && !isObjectB) {
return String(a) === String(b)
} else {
return false
}
}
}
/**
* Check if two values are loosely equal - that is,
* if they are plain objects, do they have the same shape?
*/
export function looseEqual (a, b) {
if (a === b) return true
const isObjectA = isObject(a)
const isObjectB = isObject(b)
if (isObjectA && isObjectB) {
try {
const isArrayA = Array.isArray(a)
const isArrayB = Array.isArray(b)
if (isArrayA && isArrayB) {
return a.length === b.length && a.every((e, i) => {
return looseEqual(e, b[i])
})
} else if (a instanceof Date && b instanceof Date) {
return a.getTime() === b.getTime()
} else if (!isArrayA && !isArrayB) {
const keysA = Object.keys(a)
const keysB = Object.keys(b)
return keysA.length === keysB.length && keysA.every(key => {
return looseEqual(a[key], b[key])
})
} else {
/* istanbul ignore next */
return false
}
} catch (e) {
/* istanbul ignore next */
return false
}
} else if (!isObjectA && !isObjectB) {
return String(a) === String(b)
} else {
return false
}
}
export function deepClone (vnodes, createElement) {
function cloneVNode (vnode) {
var clonedChildren = vnode.children && vnode.children.map(cloneVNode)
var cloned = createElement(vnode.tag, vnode.data, clonedChildren)
cloned.text = vnode.text
cloned.isComment = vnode.isComment
cloned.componentOptions = vnode.componentOptions
cloned.elm = vnode.elm
cloned.context = vnode.context
cloned.ns = vnode.ns
cloned.isStatic = vnode.isStatic
cloned.key = vnode.key
return cloned
}
return vnodes.map(cloneVNode)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册