-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix class-list with duplicated names
- Loading branch information
Showing
4 changed files
with
98 additions
and
22 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
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { tmpl, domBackend, composedBackend, shadowBackend, execWithWarn, } from '../base/env' | ||
import * as glassEasel from '../../src' | ||
|
||
const domHtml = (elem: glassEasel.Element): string => { | ||
const domElem = elem.getBackendElement() as unknown as Element | ||
return domElem.outerHTML | ||
} | ||
|
||
const testCases = (testBackend: glassEasel.GeneralBackendContext) => { | ||
const componentSpace = new glassEasel.ComponentSpace() | ||
componentSpace.updateComponentOptions({ | ||
writeFieldsToNode: true, | ||
writeIdToDOM: true, | ||
}) | ||
componentSpace.defineComponent({ | ||
is: '', | ||
}) | ||
|
||
it('duplicated class names', () => { | ||
const element = componentSpace.createComponentByUrl('root', '', {}, testBackend) | ||
element.setNodeClass('foo bar foo') | ||
expect(element.class).toBe('foo bar foo') | ||
expect(domHtml(element)).toBe('<root class="foo bar"></root>') | ||
element.classList!.toggle('foo', false) | ||
expect(element.class).toBe('bar foo') | ||
expect(domHtml(element)).toBe('<root class="foo bar"></root>') | ||
element.classList!.toggle('foo', false) | ||
expect(element.class).toBe('bar') | ||
expect(domHtml(element)).toBe('<root class="bar"></root>') | ||
element.classList!.toggle('foo', true) | ||
expect(element.class).toBe('bar foo') | ||
expect(domHtml(element)).toBe('<root class="bar foo"></root>') | ||
element.class = 'foo bar foo' | ||
expect(element.class).toBe('foo bar foo') | ||
expect(domHtml(element)).toBe('<root class="bar foo"></root>') | ||
element.class = 'foo bar' | ||
expect(element.class).toBe('foo bar') | ||
expect(domHtml(element)).toBe('<root class="bar foo"></root>') | ||
}) | ||
} | ||
|
||
describe('classList (DOM backend)', () => testCases(domBackend)) | ||
describe('classList (shadow backend)', () => testCases(shadowBackend)) | ||
describe('classList (composed backend)', () => testCases(composedBackend)) |