-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(runtime-dom): fix patching for attributes starting with
on
fix #949 BREAKING CHANGE: Only props starting with `on` followed by an uppercase letter or a non-letter character are considered event listeners.
- Loading branch information
Showing
8 changed files
with
72 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,37 @@ | ||
import { patchAttr, xlinkNS } from '../../src/modules/attrs' | ||
import { patchProp } from '../../src/patchProp' | ||
import { xlinkNS } from '../../src/modules/attrs' | ||
|
||
describe('attrs', () => { | ||
test('xlink attributes', () => { | ||
const el = document.createElementNS('http://www.w3.org/2000/svg', 'use') | ||
patchAttr(el, 'xlink:href', 'a', true) | ||
patchProp(el, 'xlink:href', null, 'a', true) | ||
expect(el.getAttributeNS(xlinkNS, 'href')).toBe('a') | ||
patchAttr(el, 'xlink:href', null, true) | ||
patchProp(el, 'xlink:href', 'a', null, true) | ||
expect(el.getAttributeNS(xlinkNS, 'href')).toBe(null) | ||
}) | ||
|
||
test('boolean attributes', () => { | ||
const el = document.createElement('input') | ||
patchAttr(el, 'readonly', true, false) | ||
patchProp(el, 'readonly', null, true) | ||
expect(el.getAttribute('readonly')).toBe('') | ||
patchAttr(el, 'readonly', false, false) | ||
patchProp(el, 'readonly', true, false) | ||
expect(el.getAttribute('readonly')).toBe(null) | ||
}) | ||
|
||
test('attributes', () => { | ||
const el = document.createElement('div') | ||
patchAttr(el, 'id', 'a', false) | ||
expect(el.getAttribute('id')).toBe('a') | ||
patchAttr(el, 'id', null, false) | ||
expect(el.getAttribute('id')).toBe(null) | ||
patchProp(el, 'foo', null, 'a') | ||
expect(el.getAttribute('foo')).toBe('a') | ||
patchProp(el, 'foo', 'a', null) | ||
expect(el.getAttribute('foo')).toBe(null) | ||
}) | ||
|
||
// #949 | ||
test('onxxx but non-listener attributes', () => { | ||
const el = document.createElement('div') | ||
patchProp(el, 'onwards', null, 'a') | ||
expect(el.getAttribute('onwards')).toBe('a') | ||
patchProp(el, 'onwards', 'a', null) | ||
expect(el.getAttribute('onwards')).toBe(null) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters