mirror of https://github.com/vuejs/core.git
Merge 7a91330d4f
into 56be3dd4db
This commit is contained in:
commit
fd08155354
|
@ -79,6 +79,32 @@ describe(`runtime-dom: style patching`, () => {
|
||||||
expect(el.style.width).toBe('0px')
|
expect(el.style.width).toBe('0px')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('multiple patch with boolean style value', () => {
|
||||||
|
const el = document.createElement('div')
|
||||||
|
const styleA = {
|
||||||
|
left: 0,
|
||||||
|
right: true,
|
||||||
|
top: 0,
|
||||||
|
bottom: true,
|
||||||
|
}
|
||||||
|
patchProp(el as any, 'style', null, styleA)
|
||||||
|
expect(el.style.left).toBe('0px')
|
||||||
|
expect(el.style.right).toBe('')
|
||||||
|
expect(el.style.top).toBe('0px')
|
||||||
|
expect(el.style.bottom).toBe('')
|
||||||
|
const styleB = {
|
||||||
|
left: true,
|
||||||
|
right: 0,
|
||||||
|
top: true,
|
||||||
|
bottom: 0,
|
||||||
|
}
|
||||||
|
patchProp(el as any, 'style', styleA, styleB)
|
||||||
|
expect(el.style.left).toBe('')
|
||||||
|
expect(el.style.right).toBe('0px')
|
||||||
|
expect(el.style.top).toBe('')
|
||||||
|
expect(el.style.bottom).toBe('0px')
|
||||||
|
})
|
||||||
|
|
||||||
it('should remove style attribute on falsy value', () => {
|
it('should remove style attribute on falsy value', () => {
|
||||||
const el = document.createElement('div')
|
const el = document.createElement('div')
|
||||||
el.style.cssText = 'color: red;'
|
el.style.cssText = 'color: red;'
|
||||||
|
|
|
@ -75,7 +75,7 @@ function setStyle(
|
||||||
if (isArray(val)) {
|
if (isArray(val)) {
|
||||||
val.forEach(v => setStyle(style, name, v))
|
val.forEach(v => setStyle(style, name, v))
|
||||||
} else {
|
} else {
|
||||||
if (val == null) val = ''
|
if (typeof val === 'boolean' || val == null) val = ''
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
if (semicolonRE.test(val)) {
|
if (semicolonRE.test(val)) {
|
||||||
warn(
|
warn(
|
||||||
|
|
Loading…
Reference in New Issue