Skip to content

Commit b8b104c

Browse files
committed
Remove support for non-HTML doctypes
Related to hast@2.4.0
1 parent 868517c commit b8b104c

File tree

2 files changed

+3
-65
lines changed

2 files changed

+3
-65
lines changed

index.js

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var hast = zwitch('type', {
6363
handlers: {
6464
root: wrap(assertRoot),
6565
element: wrap(assertElement),
66-
doctype: wrap(assertDoctype),
66+
doctype: _void,
6767
comment: literal,
6868
text: literal
6969
}
@@ -130,33 +130,3 @@ function assertElement(node) {
130130
'`element.tagName` should not be empty'
131131
)
132132
}
133-
134-
/**
135-
* @param {unknown} node
136-
* @returns {asserts node is Doctype}
137-
*/
138-
function assertDoctype(node) {
139-
_void(node)
140-
141-
nodeAssert.strictEqual(
142-
typeof node.name,
143-
'string',
144-
'`doctype` should have a `name`'
145-
)
146-
147-
if (node.public !== null && node.public !== undefined) {
148-
nodeAssert.strictEqual(
149-
typeof node.public,
150-
'string',
151-
'`doctype.public` should be `string`'
152-
)
153-
}
154-
155-
if (node.system !== null && node.system !== undefined) {
156-
nodeAssert.strictEqual(
157-
typeof node.system,
158-
'string',
159-
'`doctype.system` should be `string`'
160-
)
161-
}
162-
}

test/doctype.js

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,9 @@ import test from 'tape'
22
import {assert} from '../index.js'
33

44
test('assert(doctype)', function (t) {
5-
t.throws(
6-
function () {
7-
assert({type: 'doctype'})
8-
},
9-
/`doctype` should have a `name`: `{ type: 'doctype' }`$/,
10-
'should throw if a `doctype` doesn’t have a name'
11-
)
12-
13-
t.doesNotThrow(function () {
14-
assert({type: 'doctype', name: 'html'})
15-
}, 'should allow names')
16-
17-
t.doesNotThrow(function () {
18-
assert({type: 'doctype', name: ''})
19-
}, 'should allow empty names')
20-
21-
t.throws(
22-
function () {
23-
assert({type: 'doctype', name: 'html', public: true})
24-
},
25-
/`doctype.public` should be `string`: `{ type: 'doctype', name: 'html', public: true }`$/,
26-
'should throw if a `public` isn’t string'
27-
)
28-
29-
t.throws(
30-
function () {
31-
assert({type: 'doctype', name: 'html', system: false})
32-
},
33-
/`doctype.system` should be `string`: `{ type: 'doctype', name: 'html', system: false }`$/,
34-
'should throw if a `system` isn’t string'
35-
)
36-
375
t.doesNotThrow(function () {
38-
assert({type: 'doctype', name: 'html', public: 'a', system: 'b'})
39-
}, 'should allow string `public` and `system`')
6+
assert({type: 'doctype'})
7+
}, 'should allow doctypes')
408

419
t.end()
4210
})

0 commit comments

Comments
 (0)