Skip to content

Commit 64654f4

Browse files
committed
refactor: remove lodash.omit dependency
1 parent c03389d commit 64654f4

File tree

3 files changed

+2360
-5630
lines changed

3 files changed

+2360
-5630
lines changed

lib/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import omit from 'lodash.omit'
21
import matchHelper from 'posthtml-match-helper'
32

43
const plugin = (options = {}) => tree => {
@@ -16,7 +15,13 @@ const plugin = (options = {}) => tree => {
1615
if (k === 'class' && node.attrs && node.attrs.class) {
1716
node.attrs.class = [...(new Set([...node.attrs.class.split(' '), ...v.split(' ')]))].join(' ')
1817
} else {
19-
const attributes = options.overwrite ? options.attributes[key] : omit(options.attributes[key], Object.keys(node.attrs || {}))
18+
const attributesToOmit = Object.keys(node.attrs || {})
19+
const { [attributesToOmit]: _, ...remainingAttributes } = options.attributes[key]
20+
21+
const attributes = options.overwrite
22+
? options.attributes[key]
23+
: remainingAttributes
24+
2025
node.attrs = {...node.attrs, ...attributes}
2126
}
2227
}

0 commit comments

Comments
 (0)