Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vdom): add universal syncable value
PROPERTY()
Universal syncable value for assigning properties instead of attributes.
- Loading branch information
Showing
4 changed files
with
46 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { PROPERTY, SYNCABLE_VALUE_SKIP_UNDEFINED } from "../syncable_value"; | ||
|
||
describe(`PROPERTY()`, () => { | ||
test(`undefined should return SYNCABLE_VALUE_SKIP_UNDEFINED`, () => { | ||
expect(PROPERTY(undefined)).toBe(SYNCABLE_VALUE_SKIP_UNDEFINED); | ||
}); | ||
|
||
test(`value`, () => { | ||
expect(PROPERTY(1).v).toBe(1); | ||
}); | ||
|
||
test(`assign custom property`, () => { | ||
const e = document.createElement("div"); | ||
const p = PROPERTY(1); | ||
p.s(e, "_custom", void 0, 1); | ||
expect((e as any)._custom).toBe(1); | ||
}); | ||
|
||
test(`update custom property`, () => { | ||
const e = document.createElement("div"); | ||
const p = PROPERTY(1); | ||
p.s(e, "_custom", void 0, 1); | ||
p.s(e, "_custom", void 0, 2); | ||
expect((e as any)._custom).toBe(2); | ||
}); | ||
|
||
test(`update custom property with the same value`, () => { | ||
const e = document.createElement("div"); | ||
const p = PROPERTY(1); | ||
p.s(e, "_custom", void 0, 1); | ||
p.s(e, "_custom", void 0, 1); | ||
expect((e as any)._custom).toBe(1); | ||
}); | ||
}); |
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