Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/omission/closing.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ function dt(_, index, parent) {
const next = siblingAfter(parent, index)
return Boolean(
next &&
next.type === 'element' &&
(next.tagName === 'dt' || next.tagName === 'dd')
next.type === 'element' &&
(next.tagName === 'dt' || next.tagName === 'dd')
)
}

Expand Down Expand Up @@ -277,8 +277,8 @@ function thead(_, index, parent) {
const next = siblingAfter(parent, index)
return Boolean(
next &&
next.type === 'element' &&
(next.tagName === 'tbody' || next.tagName === 'tfoot')
next.type === 'element' &&
(next.tagName === 'tbody' || next.tagName === 'tfoot')
)
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"comma-separated-tokens": "^2.0.0",
"hast-util-whitespace": "^3.0.0",
"html-void-elements": "^3.0.0",
"mdast-util-to-hast": "^13.0.0",
"mdast-util-to-hast": "^13.2.1",
"property-information": "^7.0.0",
"space-separated-tokens": "^2.0.0",
"stringify-entities": "^4.0.0",
Expand Down
176 changes: 99 additions & 77 deletions test/attribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,15 @@ test('`element` attributes', async (t) => {

await t.test('should serialize unknowns set to objects', async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles a `toString` method on an object.
properties: {unknown: {toString}},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles a `toString` method on an object.
{
type: 'element',
tagName: 'i',
properties: {unknown: {toString}},
children: []
}
),
'<i unknown="yup"></i>'
)
})
Expand Down Expand Up @@ -531,13 +533,15 @@ test('`element` attributes', async (t) => {
'should serialize known numbers set to an object',
async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles a `toString` method on an object.
properties: {cols: {toString}},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles a `toString` method on an object.
{
type: 'element',
tagName: 'i',
properties: {cols: {toString}},
children: []
}
),
'<i cols="yup"></i>'
)
}
Expand Down Expand Up @@ -577,13 +581,15 @@ test('`element` attributes', async (t) => {
'should serialize known numbers set to an array of booleans',
async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles booleans in an array.
properties: {cols: [true, false]},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles booleans in an array.
{
type: 'element',
tagName: 'i',
properties: {cols: [true, false]},
children: []
}
),
'<i cols="true false"></i>'
)
}
Expand Down Expand Up @@ -717,13 +723,15 @@ test('`element` attributes', async (t) => {
'should serialize known space-separated lists set to an object',
async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles a `toString` method on an object.
properties: {className: {toString}},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles a `toString` method on an object.
{
type: 'element',
tagName: 'i',
properties: {className: {toString}},
children: []
}
),
'<i class="yup"></i>'
)
}
Expand Down Expand Up @@ -763,13 +771,15 @@ test('`element` attributes', async (t) => {
'should serialize known space-separated lists set to an array of booleans',
async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles booleans in an array.
properties: {className: [true, false]},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles booleans in an array.
{
type: 'element',
tagName: 'i',
properties: {className: [true, false]},
children: []
}
),
'<i class="true false"></i>'
)
}
Expand Down Expand Up @@ -889,13 +899,15 @@ test('`element` attributes', async (t) => {
'should serialize known comma-separated lists set to an object',
async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles a `toString` method on an object.
properties: {accept: {toString}},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles a `toString` method on an object.
{
type: 'element',
tagName: 'i',
properties: {accept: {toString}},
children: []
}
),
'<i accept="yup"></i>'
)
}
Expand Down Expand Up @@ -935,13 +947,15 @@ test('`element` attributes', async (t) => {
'should serialize known comma-separated lists set to an array of booleans',
async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles booleans in an array.
properties: {accept: [true, false]},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles booleans in an array.
{
type: 'element',
tagName: 'i',
properties: {accept: [true, false]},
children: []
}
),
'<i accept="true, false"></i>'
)
}
Expand Down Expand Up @@ -1056,13 +1070,15 @@ test('`element` attributes', async (t) => {
'should serialize known normals set to an object',
async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles a `toString` method on an object.
properties: {id: {toString}},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles a `toString` method on an object.
{
type: 'element',
tagName: 'i',
properties: {id: {toString}},
children: []
}
),
'<i id="yup"></i>'
)
}
Expand Down Expand Up @@ -1102,13 +1118,15 @@ test('`element` attributes', async (t) => {
'should serialize known normals set to an array of booleans as a space-separated list',
async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles booleans in an array.
properties: {id: [true, false]},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles booleans in an array.
{
type: 'element',
tagName: 'i',
properties: {id: [true, false]},
children: []
}
),
'<i id="true false"></i>'
)
}
Expand Down Expand Up @@ -1252,13 +1270,15 @@ test('`element` attributes', async (t) => {
'should serialize data properties set to an object',
async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles a `toString` method on an object.
properties: {dataId: {toString}},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles a `toString` method on an object.
{
type: 'element',
tagName: 'i',
properties: {dataId: {toString}},
children: []
}
),
'<i data-id="yup"></i>'
)
}
Expand Down Expand Up @@ -1298,13 +1318,15 @@ test('`element` attributes', async (t) => {
'should serialize data properties set to an array of booleans as a space-separated list',
async function () {
assert.deepEqual(
toHtml({
type: 'element',
tagName: 'i',
// @ts-expect-error: check how the runtime handles booleans in an array.
properties: {dataId: [true, false]},
children: []
}),
toHtml(
// @ts-ignore: check how the runtime handles booleans in an array.
{
type: 'element',
tagName: 'i',
properties: {dataId: [true, false]},
children: []
}
),
'<i data-id="true false"></i>'
)
}
Expand Down