File tree Expand file tree Collapse file tree 3 files changed +2360
-5630
lines changed
Expand file tree Collapse file tree 3 files changed +2360
-5630
lines changed Original file line number Diff line number Diff line change 1- import omit from 'lodash.omit'
21import matchHelper from 'posthtml-match-helper'
32
43const 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 }
You can’t perform that action at this time.
0 commit comments