Skip to content

Commit a4bcc37

Browse files
committed
Update unist-util-is
1 parent 65fead0 commit a4bcc37

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

lib/omission/closing.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
'use strict'
22

3-
var is = require('unist-util-is')
3+
var convert = require('unist-util-is/convert')
44
var element = require('hast-util-is-element')
55
var whiteSpaceLeft = require('./util/white-space-left')
66
var after = require('./util/siblings').after
77
var omission = require('./omission')
88

9+
var isComment = convert('comment')
10+
911
var optionGroup = 'optgroup'
1012
var options = ['option'].concat(optionGroup)
1113
var dataListItem = ['dt', 'dd']
@@ -85,19 +87,19 @@ module.exports = omission({
8587
// Macro for `</head>`, `</colgroup>`, and `</caption>`.
8688
function headOrColgroupOrCaption(node, index, parent) {
8789
var next = after(parent, index, true)
88-
return !next || (!is('comment', next) && !whiteSpaceLeft(next))
90+
return !next || (!isComment(next) && !whiteSpaceLeft(next))
8991
}
9092

9193
// Whether to omit `</html>`.
9294
function html(node, index, parent) {
9395
var next = after(parent, index)
94-
return !next || !is('comment', next)
96+
return !next || !isComment(next)
9597
}
9698

9799
// Whether to omit `</body>`.
98100
function body(node, index, parent) {
99101
var next = after(parent, index)
100-
return !next || !is('comment', next)
102+
return !next || !isComment(next)
101103
}
102104

103105
// Whether to omit `</p>`.

lib/omission/opening.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
var is = require('unist-util-is')
3+
var convert = require('unist-util-is/convert')
44
var element = require('hast-util-is-element')
55
var before = require('./util/siblings').before
66
var first = require('./util/first')
@@ -11,6 +11,8 @@ var omission = require('./omission')
1111

1212
var own = {}.hasOwnProperty
1313

14+
var isComment = convert('comment')
15+
1416
var uniqueHeadMetadata = ['title', 'base']
1517
var meta = ['meta', 'link', 'script', 'style', 'template']
1618
var tableContainers = ['thead', 'tbody']
@@ -27,7 +29,7 @@ module.exports = omission({
2729
// Whether to omit `<html>`.
2830
function html(node) {
2931
var head = first(node)
30-
return !head || !is('comment', head)
32+
return !head || !isComment(head)
3133
}
3234

3335
// Whether to omit `<head>`.
@@ -60,8 +62,7 @@ function body(node) {
6062
var head = first(node, true)
6163

6264
return (
63-
!head ||
64-
(!is('comment', head) && !whiteSpaceLeft(head) && !element(head, meta))
65+
!head || (!isComment(head) && !whiteSpaceLeft(head) && !element(head, meta))
6566
)
6667
}
6768

lib/omission/util/white-space-left.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
'use strict'
22

3-
var is = require('unist-util-is')
3+
var convert = require('unist-util-is/convert')
44
var whiteSpace = require('hast-util-whitespace')
55

66
module.exports = whiteSpaceLeft
77

8+
var isText = convert('text')
9+
810
// Check if `node` starts with white-space.
911
function whiteSpaceLeft(node) {
10-
return is('text', node) && whiteSpace(node.value.charAt(0))
12+
return isText(node) && whiteSpace(node.value.charAt(0))
1113
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"property-information": "^5.0.0",
2828
"space-separated-tokens": "^1.0.0",
2929
"stringify-entities": "^2.0.0",
30-
"unist-util-is": "^2.0.0",
30+
"unist-util-is": "^3.0.0",
3131
"xtend": "^4.0.1"
3232
},
3333
"devDependencies": {

0 commit comments

Comments
 (0)