Skip to content

Commit 5692e42

Browse files
committedDec 13, 2024
Refactor code-style
1 parent be2ab2d commit 5692e42

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed
 

‎lib/handle/element.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ function serializeAttribute(state, key, value) {
173173
if (info.overloadedBoolean && (value === info.attribute || value === '')) {
174174
value = true
175175
} else if (
176-
(typeof value !== 'string' || value === '' || value === info.attribute) &&
177-
(info.boolean || info.overloadedBoolean)
176+
(info.boolean || info.overloadedBoolean) &&
177+
(typeof value !== 'string' || value === info.attribute || value === '')
178178
) {
179179
value = Boolean(value)
180180
}

‎test/attribute.js

+5-18
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,8 @@ test('`element` attributes', async (t) => {
166166
'should serialize known booleans set to arbitrary strings with value',
167167
async function () {
168168
assert.deepEqual(
169-
toHtml(
170-
h('div', {
171-
selected: 'some string value for a well known boolean attribute'
172-
})
173-
),
174-
'<div selected="some string value for a well known boolean attribute"></div>'
169+
toHtml(h('div', {selected: 'something'})),
170+
'<div selected="something"></div>'
175171
)
176172
}
177173
)
@@ -180,11 +176,7 @@ test('`element` attributes', async (t) => {
180176
'should serialize known booleans set to an empty string without value',
181177
async function () {
182178
assert.deepEqual(
183-
toHtml(
184-
h('div', {
185-
selected: ''
186-
})
187-
),
179+
toHtml(h('div', {selected: ''})),
188180
'<div selected></div>'
189181
)
190182
}
@@ -194,13 +186,8 @@ test('`element` attributes', async (t) => {
194186
'should serialize known overloaded booleans set to arbitrary strings with value',
195187
async function () {
196188
assert.deepEqual(
197-
toHtml(
198-
h('div', {
199-
download:
200-
'some string value for a well known overloaded boolean attribute'
201-
})
202-
),
203-
'<div download="some string value for a well known overloaded boolean attribute"></div>'
189+
toHtml(h('div', {download: 'something'})),
190+
'<div download="something"></div>'
204191
)
205192
}
206193
)

0 commit comments

Comments
 (0)
Please sign in to comment.