htmlnano 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -12
- package/dist/_modules/collapseAttributeWhitespace.d.mts +57 -0
- package/dist/_modules/collapseAttributeWhitespace.d.ts +57 -0
- package/dist/_modules/collapseAttributeWhitespace.js +296 -0
- package/dist/_modules/collapseAttributeWhitespace.mjs +293 -0
- package/dist/_modules/collapseBooleanAttributes.d.mts +60 -0
- package/dist/_modules/collapseBooleanAttributes.d.ts +60 -0
- package/dist/_modules/collapseBooleanAttributes.js +159 -0
- package/{lib/modules → dist/_modules}/collapseBooleanAttributes.mjs +39 -57
- package/dist/_modules/collapseWhitespace.d.mts +57 -0
- package/dist/_modules/collapseWhitespace.d.ts +57 -0
- package/dist/_modules/collapseWhitespace.js +172 -0
- package/dist/_modules/collapseWhitespace.mjs +170 -0
- package/dist/_modules/custom.d.mts +57 -0
- package/dist/_modules/custom.d.ts +57 -0
- package/dist/_modules/custom.js +22 -0
- package/dist/_modules/custom.mjs +20 -0
- package/dist/_modules/deduplicateAttributeValues.d.mts +56 -0
- package/dist/_modules/deduplicateAttributeValues.d.ts +56 -0
- package/dist/_modules/deduplicateAttributeValues.js +38 -0
- package/dist/_modules/deduplicateAttributeValues.mjs +36 -0
- package/dist/_modules/example.d.mts +59 -0
- package/dist/_modules/example.d.ts +59 -0
- package/dist/_modules/example.js +67 -0
- package/dist/_modules/example.mjs +65 -0
- package/dist/_modules/mergeScripts.d.mts +56 -0
- package/dist/_modules/mergeScripts.d.ts +56 -0
- package/dist/_modules/mergeScripts.js +53 -0
- package/dist/_modules/mergeScripts.mjs +51 -0
- package/dist/_modules/mergeStyles.d.mts +56 -0
- package/dist/_modules/mergeStyles.d.ts +56 -0
- package/dist/_modules/mergeStyles.js +42 -0
- package/dist/_modules/mergeStyles.mjs +40 -0
- package/dist/_modules/minifyConditionalComments.d.mts +56 -0
- package/dist/_modules/minifyConditionalComments.d.ts +56 -0
- package/dist/_modules/minifyConditionalComments.js +54 -0
- package/{lib/modules → dist/_modules}/minifyConditionalComments.mjs +21 -22
- package/dist/_modules/minifyCss.d.mts +56 -0
- package/dist/_modules/minifyCss.d.ts +56 -0
- package/dist/_modules/minifyCss.js +84 -0
- package/dist/_modules/minifyCss.mjs +82 -0
- package/dist/_modules/minifyJs.d.mts +56 -0
- package/dist/_modules/minifyJs.d.ts +56 -0
- package/dist/_modules/minifyJs.js +108 -0
- package/dist/_modules/minifyJs.mjs +106 -0
- package/dist/_modules/minifyJson.d.mts +56 -0
- package/dist/_modules/minifyJson.d.ts +56 -0
- package/dist/_modules/minifyJson.js +35 -0
- package/dist/_modules/minifyJson.mjs +33 -0
- package/dist/_modules/minifySvg.d.mts +56 -0
- package/dist/_modules/minifySvg.d.ts +56 -0
- package/dist/_modules/minifySvg.js +40 -0
- package/dist/_modules/minifySvg.mjs +38 -0
- package/dist/_modules/minifyUrls.d.mts +56 -0
- package/dist/_modules/minifyUrls.d.ts +56 -0
- package/dist/_modules/minifyUrls.js +180 -0
- package/dist/_modules/minifyUrls.mjs +178 -0
- package/dist/_modules/normalizeAttributeValues.d.mts +56 -0
- package/dist/_modules/normalizeAttributeValues.d.ts +56 -0
- package/dist/_modules/normalizeAttributeValues.js +234 -0
- package/dist/_modules/normalizeAttributeValues.mjs +232 -0
- package/dist/_modules/removeAttributeQuotes.d.mts +56 -0
- package/dist/_modules/removeAttributeQuotes.d.ts +56 -0
- package/dist/_modules/removeAttributeQuotes.js +15 -0
- package/dist/_modules/removeAttributeQuotes.mjs +13 -0
- package/dist/_modules/removeComments.d.mts +58 -0
- package/dist/_modules/removeComments.d.ts +58 -0
- package/dist/_modules/removeComments.js +83 -0
- package/{lib/modules → dist/_modules}/removeComments.mjs +24 -35
- package/dist/_modules/removeEmptyAttributes.d.mts +56 -0
- package/dist/_modules/removeEmptyAttributes.d.ts +56 -0
- package/dist/_modules/removeEmptyAttributes.js +197 -0
- package/dist/_modules/removeEmptyAttributes.mjs +195 -0
- package/dist/_modules/removeOptionalTags.d.mts +56 -0
- package/dist/_modules/removeOptionalTags.d.ts +56 -0
- package/dist/_modules/removeOptionalTags.js +190 -0
- package/{lib/modules → dist/_modules}/removeOptionalTags.mjs +54 -91
- package/dist/_modules/removeRedundantAttributes.d.mts +57 -0
- package/dist/_modules/removeRedundantAttributes.d.ts +57 -0
- package/dist/_modules/removeRedundantAttributes.js +128 -0
- package/{lib/modules → dist/_modules}/removeRedundantAttributes.mjs +43 -59
- package/dist/_modules/removeUnusedCss.d.mts +60 -0
- package/dist/_modules/removeUnusedCss.d.ts +60 -0
- package/dist/_modules/removeUnusedCss.js +134 -0
- package/dist/_modules/removeUnusedCss.mjs +132 -0
- package/dist/_modules/sortAttributes.d.mts +57 -0
- package/dist/_modules/sortAttributes.d.ts +57 -0
- package/dist/_modules/sortAttributes.js +102 -0
- package/{lib/modules → dist/_modules}/sortAttributes.mjs +39 -58
- package/dist/_modules/sortAttributesWithLists.d.mts +56 -0
- package/dist/_modules/sortAttributesWithLists.d.ts +56 -0
- package/dist/_modules/sortAttributesWithLists.js +118 -0
- package/{lib/modules → dist/_modules}/sortAttributesWithLists.mjs +41 -59
- package/dist/helpers.js +72 -0
- package/dist/helpers.mjs +63 -0
- package/dist/index.js +223 -0
- package/dist/index.mjs +209 -0
- package/dist/presets/ampSafe.js +19 -0
- package/{lib → dist}/presets/ampSafe.mjs +6 -4
- package/dist/presets/max.js +28 -0
- package/{lib → dist}/presets/max.mjs +6 -4
- package/dist/presets/safe.js +60 -0
- package/{lib → dist}/presets/safe.mjs +13 -20
- package/package.json +48 -56
- package/.eslintignore +0 -3
- package/CHANGELOG.md +0 -409
- package/docs/README.md +0 -33
- package/docs/babel.config.js +0 -3
- package/docs/docs/010-introduction.md +0 -22
- package/docs/docs/020-usage.md +0 -117
- package/docs/docs/030-config.md +0 -21
- package/docs/docs/040-presets.md +0 -75
- package/docs/docs/050-modules.md +0 -855
- package/docs/docs/060-contribute.md +0 -16
- package/docs/docusaurus.config.js +0 -65
- package/docs/netlify.toml +0 -4
- package/docs/package-lock.json +0 -21630
- package/docs/package.json +0 -40
- package/docs/sidebars.js +0 -26
- package/docs/versioned_docs/version-1.1.1/010-introduction.md +0 -22
- package/docs/versioned_docs/version-1.1.1/020-usage.md +0 -77
- package/docs/versioned_docs/version-1.1.1/030-config.md +0 -21
- package/docs/versioned_docs/version-1.1.1/040-presets.md +0 -75
- package/docs/versioned_docs/version-1.1.1/050-modules.md +0 -785
- package/docs/versioned_docs/version-1.1.1/060-contribute.md +0 -16
- package/docs/versioned_docs/version-2.0.0/010-introduction.md +0 -22
- package/docs/versioned_docs/version-2.0.0/020-usage.md +0 -77
- package/docs/versioned_docs/version-2.0.0/030-config.md +0 -21
- package/docs/versioned_docs/version-2.0.0/040-presets.md +0 -75
- package/docs/versioned_docs/version-2.0.0/050-modules.md +0 -838
- package/docs/versioned_docs/version-2.0.0/060-contribute.md +0 -16
- package/docs/versioned_sidebars/version-1.1.1-sidebars.json +0 -8
- package/docs/versioned_sidebars/version-2.0.0-sidebars.json +0 -8
- package/docs/versions.json +0 -4
- package/index.cjs +0 -11
- package/index.d.cts +0 -3
- package/index.d.mts +0 -3
- package/index.d.ts +0 -94
- package/index.mjs +0 -2
- package/lib/helpers.cjs +0 -79
- package/lib/helpers.mjs +0 -53
- package/lib/htmlnano.cjs +0 -202
- package/lib/htmlnano.mjs +0 -198
- package/lib/modules/collapseAttributeWhitespace.cjs +0 -86
- package/lib/modules/collapseAttributeWhitespace.mjs +0 -104
- package/lib/modules/collapseBooleanAttributes.cjs +0 -62
- package/lib/modules/collapseWhitespace.cjs +0 -100
- package/lib/modules/collapseWhitespace.mjs +0 -132
- package/lib/modules/custom.cjs +0 -19
- package/lib/modules/custom.mjs +0 -16
- package/lib/modules/deduplicateAttributeValues.cjs +0 -38
- package/lib/modules/deduplicateAttributeValues.mjs +0 -40
- package/lib/modules/example.cjs +0 -85
- package/lib/modules/example.mjs +0 -75
- package/lib/modules/mergeScripts.cjs +0 -54
- package/lib/modules/mergeScripts.mjs +0 -56
- package/lib/modules/mergeStyles.cjs +0 -38
- package/lib/modules/mergeStyles.mjs +0 -36
- package/lib/modules/minifyConditionalComments.cjs +0 -47
- package/lib/modules/minifyCss.cjs +0 -73
- package/lib/modules/minifyCss.mjs +0 -88
- package/lib/modules/minifyJs.cjs +0 -103
- package/lib/modules/minifyJs.mjs +0 -121
- package/lib/modules/minifyJson.cjs +0 -24
- package/lib/modules/minifyJson.mjs +0 -21
- package/lib/modules/minifySvg.cjs +0 -37
- package/lib/modules/minifySvg.mjs +0 -30
- package/lib/modules/minifyUrls.cjs +0 -141
- package/lib/modules/minifyUrls.mjs +0 -229
- package/lib/modules/normalizeAttributeValues.cjs +0 -120
- package/lib/modules/normalizeAttributeValues.mjs +0 -140
- package/lib/modules/removeAttributeQuotes.cjs +0 -17
- package/lib/modules/removeAttributeQuotes.mjs +0 -12
- package/lib/modules/removeComments.cjs +0 -86
- package/lib/modules/removeEmptyAttributes.cjs +0 -72
- package/lib/modules/removeEmptyAttributes.mjs +0 -121
- package/lib/modules/removeOptionalTags.cjs +0 -183
- package/lib/modules/removeRedundantAttributes.cjs +0 -112
- package/lib/modules/removeUnusedCss.cjs +0 -113
- package/lib/modules/removeUnusedCss.mjs +0 -122
- package/lib/modules/sortAttributes.cjs +0 -98
- package/lib/modules/sortAttributesWithLists.cjs +0 -114
- package/lib/presets/ampSafe.cjs +0 -18
- package/lib/presets/max.cjs +0 -27
- package/lib/presets/safe.cjs +0 -65
- package/test.js +0 -23
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
// Specification: https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
|
4
|
+
// See also: https://github.com/posthtml/posthtml-render/pull/30
|
|
5
|
+
// See also: https://github.com/posthtml/htmlnano/issues/6#issuecomment-707105334
|
|
6
|
+
/** Disable quoteAllAttributes while not overriding the configuration */ const mod = {
|
|
7
|
+
default: function removeAttributeQuotes(tree) {
|
|
8
|
+
var _tree_options;
|
|
9
|
+
var _quoteAllAttributes;
|
|
10
|
+
if (tree.options) (_quoteAllAttributes = (_tree_options = tree.options).quoteAllAttributes) != null ? _quoteAllAttributes : _tree_options.quoteAllAttributes = false;
|
|
11
|
+
return tree;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.default = mod;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Specification: https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
|
2
|
+
// See also: https://github.com/posthtml/posthtml-render/pull/30
|
|
3
|
+
// See also: https://github.com/posthtml/htmlnano/issues/6#issuecomment-707105334
|
|
4
|
+
/** Disable quoteAllAttributes while not overriding the configuration */ const mod = {
|
|
5
|
+
default: function removeAttributeQuotes(tree) {
|
|
6
|
+
var _tree_options;
|
|
7
|
+
var _quoteAllAttributes;
|
|
8
|
+
if (tree.options) (_quoteAllAttributes = (_tree_options = tree.options).quoteAllAttributes) != null ? _quoteAllAttributes : _tree_options.quoteAllAttributes = false;
|
|
9
|
+
return tree;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { mod as default };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import PostHTML from 'posthtml';
|
|
2
|
+
import { MinifyOptions } from 'terser';
|
|
3
|
+
import { Options } from 'cssnano';
|
|
4
|
+
import { Config } from 'svgo';
|
|
5
|
+
|
|
6
|
+
type PostHTMLTreeLike = [PostHTML.Node] & PostHTML.NodeAPI & {
|
|
7
|
+
options?: {
|
|
8
|
+
quoteAllAttributes?: boolean | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
render(): string;
|
|
11
|
+
render(node: PostHTML.Node | PostHTMLTreeLike, renderOptions?: any): string;
|
|
12
|
+
};
|
|
13
|
+
type MaybeArray<T> = T | Array<T>;
|
|
14
|
+
type PostHTMLNodeLike = PostHTML.Node | string;
|
|
15
|
+
interface HtmlnanoOptions {
|
|
16
|
+
skipConfigLoading?: boolean;
|
|
17
|
+
skipInternalWarnings?: boolean;
|
|
18
|
+
collapseAttributeWhitespace?: boolean;
|
|
19
|
+
collapseBooleanAttributes?: {
|
|
20
|
+
amphtml?: boolean;
|
|
21
|
+
};
|
|
22
|
+
collapseWhitespace?: 'conservative' | 'all' | 'aggressive';
|
|
23
|
+
custom?: MaybeArray<(tree: PostHTMLTreeLike, options?: any) => (PostHTML.Node | PostHTMLTreeLike)>;
|
|
24
|
+
deduplicateAttributeValues?: boolean;
|
|
25
|
+
minifyUrls?: URL | string | false;
|
|
26
|
+
mergeStyles?: boolean;
|
|
27
|
+
mergeScripts?: boolean;
|
|
28
|
+
minifyCss?: Options | boolean;
|
|
29
|
+
minifyConditionalComments?: boolean;
|
|
30
|
+
minifyJs?: MinifyOptions | boolean;
|
|
31
|
+
minifyJson?: boolean;
|
|
32
|
+
minifySvg?: Config | boolean;
|
|
33
|
+
normalizeAttributeValues?: boolean;
|
|
34
|
+
removeAttributeQuotes?: boolean;
|
|
35
|
+
removeComments?: boolean | 'safe' | 'all' | RegExp | ((comment: string) => boolean);
|
|
36
|
+
removeEmptyAttributes?: boolean;
|
|
37
|
+
removeRedundantAttributes?: boolean;
|
|
38
|
+
removeOptionalTags?: boolean;
|
|
39
|
+
removeUnusedCss?: boolean;
|
|
40
|
+
sortAttributes?: boolean | 'alphabetical' | 'frequency';
|
|
41
|
+
sortAttributesWithLists?: boolean | 'alphabetical' | 'frequency';
|
|
42
|
+
}
|
|
43
|
+
type HtmlnanoModuleAttrsHandler = (attrs: Record<string, string | boolean | void>, node: PostHTML.Node) => Record<string, string | boolean | void>;
|
|
44
|
+
type HtmlnanoModuleContentHandler = (content: Array<PostHTMLNodeLike>, node: PostHTML.Node) => MaybeArray<PostHTMLNodeLike>;
|
|
45
|
+
type HtmlnanoModuleNodeHandler = (node: PostHTMLNodeLike) => PostHTML.Node | string;
|
|
46
|
+
type OptionalOptions<T> = T extends boolean | string | Function | number | null | undefined ? T : T extends object ? Partial<T> : T;
|
|
47
|
+
type HtmlnanoModule<Options = any> = {
|
|
48
|
+
onAttrs?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleAttrsHandler;
|
|
49
|
+
onContent?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleContentHandler;
|
|
50
|
+
onNode?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleNodeHandler;
|
|
51
|
+
default?: (tree: PostHTMLTreeLike, options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => PostHTMLTreeLike | Promise<PostHTMLTreeLike>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type RemoveCommentsOptions = boolean | 'safe' | 'all' | RegExp | ((comment: string) => boolean);
|
|
55
|
+
declare const mod: HtmlnanoModule<RemoveCommentsOptions>;
|
|
56
|
+
|
|
57
|
+
export { mod as default };
|
|
58
|
+
export type { RemoveCommentsOptions };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import PostHTML from 'posthtml';
|
|
2
|
+
import { MinifyOptions } from 'terser';
|
|
3
|
+
import { Options } from 'cssnano';
|
|
4
|
+
import { Config } from 'svgo';
|
|
5
|
+
|
|
6
|
+
type PostHTMLTreeLike = [PostHTML.Node] & PostHTML.NodeAPI & {
|
|
7
|
+
options?: {
|
|
8
|
+
quoteAllAttributes?: boolean | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
render(): string;
|
|
11
|
+
render(node: PostHTML.Node | PostHTMLTreeLike, renderOptions?: any): string;
|
|
12
|
+
};
|
|
13
|
+
type MaybeArray<T> = T | Array<T>;
|
|
14
|
+
type PostHTMLNodeLike = PostHTML.Node | string;
|
|
15
|
+
interface HtmlnanoOptions {
|
|
16
|
+
skipConfigLoading?: boolean;
|
|
17
|
+
skipInternalWarnings?: boolean;
|
|
18
|
+
collapseAttributeWhitespace?: boolean;
|
|
19
|
+
collapseBooleanAttributes?: {
|
|
20
|
+
amphtml?: boolean;
|
|
21
|
+
};
|
|
22
|
+
collapseWhitespace?: 'conservative' | 'all' | 'aggressive';
|
|
23
|
+
custom?: MaybeArray<(tree: PostHTMLTreeLike, options?: any) => (PostHTML.Node | PostHTMLTreeLike)>;
|
|
24
|
+
deduplicateAttributeValues?: boolean;
|
|
25
|
+
minifyUrls?: URL | string | false;
|
|
26
|
+
mergeStyles?: boolean;
|
|
27
|
+
mergeScripts?: boolean;
|
|
28
|
+
minifyCss?: Options | boolean;
|
|
29
|
+
minifyConditionalComments?: boolean;
|
|
30
|
+
minifyJs?: MinifyOptions | boolean;
|
|
31
|
+
minifyJson?: boolean;
|
|
32
|
+
minifySvg?: Config | boolean;
|
|
33
|
+
normalizeAttributeValues?: boolean;
|
|
34
|
+
removeAttributeQuotes?: boolean;
|
|
35
|
+
removeComments?: boolean | 'safe' | 'all' | RegExp | ((comment: string) => boolean);
|
|
36
|
+
removeEmptyAttributes?: boolean;
|
|
37
|
+
removeRedundantAttributes?: boolean;
|
|
38
|
+
removeOptionalTags?: boolean;
|
|
39
|
+
removeUnusedCss?: boolean;
|
|
40
|
+
sortAttributes?: boolean | 'alphabetical' | 'frequency';
|
|
41
|
+
sortAttributesWithLists?: boolean | 'alphabetical' | 'frequency';
|
|
42
|
+
}
|
|
43
|
+
type HtmlnanoModuleAttrsHandler = (attrs: Record<string, string | boolean | void>, node: PostHTML.Node) => Record<string, string | boolean | void>;
|
|
44
|
+
type HtmlnanoModuleContentHandler = (content: Array<PostHTMLNodeLike>, node: PostHTML.Node) => MaybeArray<PostHTMLNodeLike>;
|
|
45
|
+
type HtmlnanoModuleNodeHandler = (node: PostHTMLNodeLike) => PostHTML.Node | string;
|
|
46
|
+
type OptionalOptions<T> = T extends boolean | string | Function | number | null | undefined ? T : T extends object ? Partial<T> : T;
|
|
47
|
+
type HtmlnanoModule<Options = any> = {
|
|
48
|
+
onAttrs?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleAttrsHandler;
|
|
49
|
+
onContent?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleContentHandler;
|
|
50
|
+
onNode?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleNodeHandler;
|
|
51
|
+
default?: (tree: PostHTMLTreeLike, options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => PostHTMLTreeLike | Promise<PostHTMLTreeLike>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type RemoveCommentsOptions = boolean | 'safe' | 'all' | RegExp | ((comment: string) => boolean);
|
|
55
|
+
declare const mod: HtmlnanoModule<RemoveCommentsOptions>;
|
|
56
|
+
|
|
57
|
+
export { mod as default };
|
|
58
|
+
export type { RemoveCommentsOptions };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
var helpers_js = require('../helpers.js');
|
|
4
|
+
|
|
5
|
+
const MATCH_EXCERPT_REGEXP = /<!-- ?more ?-->/i;
|
|
6
|
+
/** Removes HTML comments */ const mod = {
|
|
7
|
+
onNode (_, removeType) {
|
|
8
|
+
if (removeType !== 'all' && removeType !== 'safe' && !isMatcher(removeType)) {
|
|
9
|
+
removeType = 'safe';
|
|
10
|
+
}
|
|
11
|
+
return (node)=>{
|
|
12
|
+
if (isCommentToRemove(node, removeType)) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
return node;
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
onContent (_, removeType) {
|
|
19
|
+
if (removeType !== 'all' && removeType !== 'safe' && !isMatcher(removeType)) {
|
|
20
|
+
removeType = 'safe';
|
|
21
|
+
}
|
|
22
|
+
return (contents)=>{
|
|
23
|
+
return contents.filter((content)=>!isCommentToRemove(content, removeType));
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function isCommentToRemove(text, removeType) {
|
|
28
|
+
if (typeof text !== 'string') {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (!helpers_js.isComment(text)) {
|
|
32
|
+
// Not HTML comment
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (removeType === 'safe') {
|
|
36
|
+
const isNoindex = text === '<!--noindex-->' || text === '<!--/noindex-->';
|
|
37
|
+
// Don't remove noindex comments.
|
|
38
|
+
// See: https://yandex.com/support/webmaster/controlling-robot/html.xml
|
|
39
|
+
if (isNoindex) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const isServerSideExclude = text === '<!--sse-->' || text === '<!--/sse-->';
|
|
43
|
+
// Don't remove sse comments.
|
|
44
|
+
// See: https://support.cloudflare.com/hc/en-us/articles/200170036-What-does-Server-Side-Excludes-SSE-do-
|
|
45
|
+
if (isServerSideExclude) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
// https://en.wikipedia.org/wiki/Conditional_comment
|
|
49
|
+
if (helpers_js.isConditionalComment(text)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
// Hexo: https://hexo.io/docs/tag-plugins#Post-Excerpt
|
|
53
|
+
// Hugo: https://gohugo.io/content-management/summaries/#manual-summary-splitting
|
|
54
|
+
// WordPress: https://wordpress.com/support/wordpress-editor/blocks/more-block/2/
|
|
55
|
+
// Jekyll: https://jekyllrb.com/docs/posts/#post-excerpts
|
|
56
|
+
const isCMSExcerptComment = MATCH_EXCERPT_REGEXP.test(text);
|
|
57
|
+
if (isCMSExcerptComment) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (isMatcher(removeType)) {
|
|
62
|
+
return isMatch(text, removeType);
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
function isMatch(input, matcher) {
|
|
67
|
+
if (matcher instanceof RegExp) {
|
|
68
|
+
return matcher.test(input);
|
|
69
|
+
}
|
|
70
|
+
if (typeof matcher === 'function') {
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call -- typescript incorrectly infers Partialled type
|
|
72
|
+
return !!matcher(input);
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
function isMatcher(matcher) {
|
|
77
|
+
if (matcher instanceof RegExp || typeof matcher === 'function') {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.default = mod;
|
|
@@ -1,39 +1,35 @@
|
|
|
1
1
|
import { isComment, isConditionalComment } from '../helpers.mjs';
|
|
2
2
|
|
|
3
3
|
const MATCH_EXCERPT_REGEXP = /<!-- ?more ?-->/i;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
removeType = 'safe';
|
|
9
|
-
}
|
|
10
|
-
return (node) => {
|
|
11
|
-
if (isCommentToRemove(node, removeType)) {
|
|
12
|
-
return '';
|
|
4
|
+
/** Removes HTML comments */ const mod = {
|
|
5
|
+
onNode (_, removeType) {
|
|
6
|
+
if (removeType !== 'all' && removeType !== 'safe' && !isMatcher(removeType)) {
|
|
7
|
+
removeType = 'safe';
|
|
13
8
|
}
|
|
14
|
-
return node
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
return (node)=>{
|
|
10
|
+
if (isCommentToRemove(node, removeType)) {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
return node;
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
onContent (_, removeType) {
|
|
17
|
+
if (removeType !== 'all' && removeType !== 'safe' && !isMatcher(removeType)) {
|
|
18
|
+
removeType = 'safe';
|
|
19
|
+
}
|
|
20
|
+
return (contents)=>{
|
|
21
|
+
return contents.filter((content)=>!isCommentToRemove(content, removeType));
|
|
22
|
+
};
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
return contents.filter(content => ! isCommentToRemove(content, removeType));
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
24
|
+
};
|
|
27
25
|
function isCommentToRemove(text, removeType) {
|
|
28
26
|
if (typeof text !== 'string') {
|
|
29
27
|
return false;
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
if (! isComment(text)) {
|
|
29
|
+
if (!isComment(text)) {
|
|
33
30
|
// Not HTML comment
|
|
34
31
|
return false;
|
|
35
32
|
}
|
|
36
|
-
|
|
37
33
|
if (removeType === 'safe') {
|
|
38
34
|
const isNoindex = text === '<!--noindex-->' || text === '<!--/noindex-->';
|
|
39
35
|
// Don't remove noindex comments.
|
|
@@ -41,19 +37,16 @@ function isCommentToRemove(text, removeType) {
|
|
|
41
37
|
if (isNoindex) {
|
|
42
38
|
return false;
|
|
43
39
|
}
|
|
44
|
-
|
|
45
40
|
const isServerSideExclude = text === '<!--sse-->' || text === '<!--/sse-->';
|
|
46
41
|
// Don't remove sse comments.
|
|
47
42
|
// See: https://support.cloudflare.com/hc/en-us/articles/200170036-What-does-Server-Side-Excludes-SSE-do-
|
|
48
43
|
if (isServerSideExclude) {
|
|
49
44
|
return false;
|
|
50
45
|
}
|
|
51
|
-
|
|
52
46
|
// https://en.wikipedia.org/wiki/Conditional_comment
|
|
53
47
|
if (isConditionalComment(text)) {
|
|
54
48
|
return false;
|
|
55
49
|
}
|
|
56
|
-
|
|
57
50
|
// Hexo: https://hexo.io/docs/tag-plugins#Post-Excerpt
|
|
58
51
|
// Hugo: https://gohugo.io/content-management/summaries/#manual-summary-splitting
|
|
59
52
|
// WordPress: https://wordpress.com/support/wordpress-editor/blocks/more-block/2/
|
|
@@ -63,30 +56,26 @@ function isCommentToRemove(text, removeType) {
|
|
|
63
56
|
return false;
|
|
64
57
|
}
|
|
65
58
|
}
|
|
66
|
-
|
|
67
59
|
if (isMatcher(removeType)) {
|
|
68
60
|
return isMatch(text, removeType);
|
|
69
61
|
}
|
|
70
|
-
|
|
71
62
|
return true;
|
|
72
63
|
}
|
|
73
|
-
|
|
74
64
|
function isMatch(input, matcher) {
|
|
75
65
|
if (matcher instanceof RegExp) {
|
|
76
66
|
return matcher.test(input);
|
|
77
67
|
}
|
|
78
|
-
|
|
79
68
|
if (typeof matcher === 'function') {
|
|
80
|
-
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call -- typescript incorrectly infers Partialled type
|
|
70
|
+
return !!matcher(input);
|
|
81
71
|
}
|
|
82
|
-
|
|
83
72
|
return false;
|
|
84
73
|
}
|
|
85
|
-
|
|
86
74
|
function isMatcher(matcher) {
|
|
87
75
|
if (matcher instanceof RegExp || typeof matcher === 'function') {
|
|
88
76
|
return true;
|
|
89
77
|
}
|
|
90
|
-
|
|
91
78
|
return false;
|
|
92
79
|
}
|
|
80
|
+
|
|
81
|
+
export { mod as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import PostHTML from 'posthtml';
|
|
2
|
+
import { MinifyOptions } from 'terser';
|
|
3
|
+
import { Options } from 'cssnano';
|
|
4
|
+
import { Config } from 'svgo';
|
|
5
|
+
|
|
6
|
+
type PostHTMLTreeLike = [PostHTML.Node] & PostHTML.NodeAPI & {
|
|
7
|
+
options?: {
|
|
8
|
+
quoteAllAttributes?: boolean | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
render(): string;
|
|
11
|
+
render(node: PostHTML.Node | PostHTMLTreeLike, renderOptions?: any): string;
|
|
12
|
+
};
|
|
13
|
+
type MaybeArray<T> = T | Array<T>;
|
|
14
|
+
type PostHTMLNodeLike = PostHTML.Node | string;
|
|
15
|
+
interface HtmlnanoOptions {
|
|
16
|
+
skipConfigLoading?: boolean;
|
|
17
|
+
skipInternalWarnings?: boolean;
|
|
18
|
+
collapseAttributeWhitespace?: boolean;
|
|
19
|
+
collapseBooleanAttributes?: {
|
|
20
|
+
amphtml?: boolean;
|
|
21
|
+
};
|
|
22
|
+
collapseWhitespace?: 'conservative' | 'all' | 'aggressive';
|
|
23
|
+
custom?: MaybeArray<(tree: PostHTMLTreeLike, options?: any) => (PostHTML.Node | PostHTMLTreeLike)>;
|
|
24
|
+
deduplicateAttributeValues?: boolean;
|
|
25
|
+
minifyUrls?: URL | string | false;
|
|
26
|
+
mergeStyles?: boolean;
|
|
27
|
+
mergeScripts?: boolean;
|
|
28
|
+
minifyCss?: Options | boolean;
|
|
29
|
+
minifyConditionalComments?: boolean;
|
|
30
|
+
minifyJs?: MinifyOptions | boolean;
|
|
31
|
+
minifyJson?: boolean;
|
|
32
|
+
minifySvg?: Config | boolean;
|
|
33
|
+
normalizeAttributeValues?: boolean;
|
|
34
|
+
removeAttributeQuotes?: boolean;
|
|
35
|
+
removeComments?: boolean | 'safe' | 'all' | RegExp | ((comment: string) => boolean);
|
|
36
|
+
removeEmptyAttributes?: boolean;
|
|
37
|
+
removeRedundantAttributes?: boolean;
|
|
38
|
+
removeOptionalTags?: boolean;
|
|
39
|
+
removeUnusedCss?: boolean;
|
|
40
|
+
sortAttributes?: boolean | 'alphabetical' | 'frequency';
|
|
41
|
+
sortAttributesWithLists?: boolean | 'alphabetical' | 'frequency';
|
|
42
|
+
}
|
|
43
|
+
type HtmlnanoModuleAttrsHandler = (attrs: Record<string, string | boolean | void>, node: PostHTML.Node) => Record<string, string | boolean | void>;
|
|
44
|
+
type HtmlnanoModuleContentHandler = (content: Array<PostHTMLNodeLike>, node: PostHTML.Node) => MaybeArray<PostHTMLNodeLike>;
|
|
45
|
+
type HtmlnanoModuleNodeHandler = (node: PostHTMLNodeLike) => PostHTML.Node | string;
|
|
46
|
+
type OptionalOptions<T> = T extends boolean | string | Function | number | null | undefined ? T : T extends object ? Partial<T> : T;
|
|
47
|
+
type HtmlnanoModule<Options = any> = {
|
|
48
|
+
onAttrs?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleAttrsHandler;
|
|
49
|
+
onContent?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleContentHandler;
|
|
50
|
+
onNode?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleNodeHandler;
|
|
51
|
+
default?: (tree: PostHTMLTreeLike, options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => PostHTMLTreeLike | Promise<PostHTMLTreeLike>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
declare const mod: HtmlnanoModule;
|
|
55
|
+
|
|
56
|
+
export { mod as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import PostHTML from 'posthtml';
|
|
2
|
+
import { MinifyOptions } from 'terser';
|
|
3
|
+
import { Options } from 'cssnano';
|
|
4
|
+
import { Config } from 'svgo';
|
|
5
|
+
|
|
6
|
+
type PostHTMLTreeLike = [PostHTML.Node] & PostHTML.NodeAPI & {
|
|
7
|
+
options?: {
|
|
8
|
+
quoteAllAttributes?: boolean | undefined;
|
|
9
|
+
} | undefined;
|
|
10
|
+
render(): string;
|
|
11
|
+
render(node: PostHTML.Node | PostHTMLTreeLike, renderOptions?: any): string;
|
|
12
|
+
};
|
|
13
|
+
type MaybeArray<T> = T | Array<T>;
|
|
14
|
+
type PostHTMLNodeLike = PostHTML.Node | string;
|
|
15
|
+
interface HtmlnanoOptions {
|
|
16
|
+
skipConfigLoading?: boolean;
|
|
17
|
+
skipInternalWarnings?: boolean;
|
|
18
|
+
collapseAttributeWhitespace?: boolean;
|
|
19
|
+
collapseBooleanAttributes?: {
|
|
20
|
+
amphtml?: boolean;
|
|
21
|
+
};
|
|
22
|
+
collapseWhitespace?: 'conservative' | 'all' | 'aggressive';
|
|
23
|
+
custom?: MaybeArray<(tree: PostHTMLTreeLike, options?: any) => (PostHTML.Node | PostHTMLTreeLike)>;
|
|
24
|
+
deduplicateAttributeValues?: boolean;
|
|
25
|
+
minifyUrls?: URL | string | false;
|
|
26
|
+
mergeStyles?: boolean;
|
|
27
|
+
mergeScripts?: boolean;
|
|
28
|
+
minifyCss?: Options | boolean;
|
|
29
|
+
minifyConditionalComments?: boolean;
|
|
30
|
+
minifyJs?: MinifyOptions | boolean;
|
|
31
|
+
minifyJson?: boolean;
|
|
32
|
+
minifySvg?: Config | boolean;
|
|
33
|
+
normalizeAttributeValues?: boolean;
|
|
34
|
+
removeAttributeQuotes?: boolean;
|
|
35
|
+
removeComments?: boolean | 'safe' | 'all' | RegExp | ((comment: string) => boolean);
|
|
36
|
+
removeEmptyAttributes?: boolean;
|
|
37
|
+
removeRedundantAttributes?: boolean;
|
|
38
|
+
removeOptionalTags?: boolean;
|
|
39
|
+
removeUnusedCss?: boolean;
|
|
40
|
+
sortAttributes?: boolean | 'alphabetical' | 'frequency';
|
|
41
|
+
sortAttributesWithLists?: boolean | 'alphabetical' | 'frequency';
|
|
42
|
+
}
|
|
43
|
+
type HtmlnanoModuleAttrsHandler = (attrs: Record<string, string | boolean | void>, node: PostHTML.Node) => Record<string, string | boolean | void>;
|
|
44
|
+
type HtmlnanoModuleContentHandler = (content: Array<PostHTMLNodeLike>, node: PostHTML.Node) => MaybeArray<PostHTMLNodeLike>;
|
|
45
|
+
type HtmlnanoModuleNodeHandler = (node: PostHTMLNodeLike) => PostHTML.Node | string;
|
|
46
|
+
type OptionalOptions<T> = T extends boolean | string | Function | number | null | undefined ? T : T extends object ? Partial<T> : T;
|
|
47
|
+
type HtmlnanoModule<Options = any> = {
|
|
48
|
+
onAttrs?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleAttrsHandler;
|
|
49
|
+
onContent?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleContentHandler;
|
|
50
|
+
onNode?: (options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => HtmlnanoModuleNodeHandler;
|
|
51
|
+
default?: (tree: PostHTMLTreeLike, options: Partial<HtmlnanoOptions>, moduleOptions: OptionalOptions<Options>) => PostHTMLTreeLike | Promise<PostHTMLTreeLike>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
declare const mod: HtmlnanoModule;
|
|
55
|
+
|
|
56
|
+
export { mod as default };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
|
|
3
|
+
var helpers_js = require('../helpers.js');
|
|
4
|
+
|
|
5
|
+
const safeToRemoveAttrs = {
|
|
6
|
+
id: null,
|
|
7
|
+
class: null,
|
|
8
|
+
style: null,
|
|
9
|
+
title: null,
|
|
10
|
+
lang: null,
|
|
11
|
+
dir: null,
|
|
12
|
+
abbr: [
|
|
13
|
+
'th'
|
|
14
|
+
],
|
|
15
|
+
accept: [
|
|
16
|
+
'input'
|
|
17
|
+
],
|
|
18
|
+
'accept-charset': [
|
|
19
|
+
'form'
|
|
20
|
+
],
|
|
21
|
+
charset: [
|
|
22
|
+
'meta',
|
|
23
|
+
'script'
|
|
24
|
+
],
|
|
25
|
+
action: [
|
|
26
|
+
'form'
|
|
27
|
+
],
|
|
28
|
+
cols: [
|
|
29
|
+
'textarea'
|
|
30
|
+
],
|
|
31
|
+
colspan: [
|
|
32
|
+
'td',
|
|
33
|
+
'th'
|
|
34
|
+
],
|
|
35
|
+
coords: [
|
|
36
|
+
'area'
|
|
37
|
+
],
|
|
38
|
+
dirname: [
|
|
39
|
+
'input',
|
|
40
|
+
'textarea'
|
|
41
|
+
],
|
|
42
|
+
dropzone: null,
|
|
43
|
+
headers: [
|
|
44
|
+
'td',
|
|
45
|
+
'th'
|
|
46
|
+
],
|
|
47
|
+
form: [
|
|
48
|
+
'button',
|
|
49
|
+
'fieldset',
|
|
50
|
+
'input',
|
|
51
|
+
'keygen',
|
|
52
|
+
'object',
|
|
53
|
+
'output',
|
|
54
|
+
'select',
|
|
55
|
+
'textarea'
|
|
56
|
+
],
|
|
57
|
+
formaction: [
|
|
58
|
+
'button',
|
|
59
|
+
'input'
|
|
60
|
+
],
|
|
61
|
+
height: [
|
|
62
|
+
'canvas',
|
|
63
|
+
'embed',
|
|
64
|
+
'iframe',
|
|
65
|
+
'img',
|
|
66
|
+
'input',
|
|
67
|
+
'object',
|
|
68
|
+
'video'
|
|
69
|
+
],
|
|
70
|
+
high: 'meter',
|
|
71
|
+
href: 'link',
|
|
72
|
+
list: 'input',
|
|
73
|
+
low: 'meter',
|
|
74
|
+
manifest: 'html',
|
|
75
|
+
max: [
|
|
76
|
+
'meter',
|
|
77
|
+
'progress'
|
|
78
|
+
],
|
|
79
|
+
maxLength: [
|
|
80
|
+
'input',
|
|
81
|
+
'textarea'
|
|
82
|
+
],
|
|
83
|
+
menu: 'button',
|
|
84
|
+
min: 'meter',
|
|
85
|
+
minLength: [
|
|
86
|
+
'input',
|
|
87
|
+
'textarea'
|
|
88
|
+
],
|
|
89
|
+
name: [
|
|
90
|
+
'button',
|
|
91
|
+
'fieldset',
|
|
92
|
+
'input',
|
|
93
|
+
'keygen',
|
|
94
|
+
'output',
|
|
95
|
+
'select',
|
|
96
|
+
'textarea',
|
|
97
|
+
'form',
|
|
98
|
+
'map',
|
|
99
|
+
'meta',
|
|
100
|
+
'param',
|
|
101
|
+
'slot'
|
|
102
|
+
],
|
|
103
|
+
pattern: [
|
|
104
|
+
'input'
|
|
105
|
+
],
|
|
106
|
+
ping: [
|
|
107
|
+
'a',
|
|
108
|
+
'area'
|
|
109
|
+
],
|
|
110
|
+
placeholder: [
|
|
111
|
+
'input',
|
|
112
|
+
'textarea'
|
|
113
|
+
],
|
|
114
|
+
poster: [
|
|
115
|
+
'video'
|
|
116
|
+
],
|
|
117
|
+
rel: [
|
|
118
|
+
'a',
|
|
119
|
+
'area',
|
|
120
|
+
'link'
|
|
121
|
+
],
|
|
122
|
+
rows: 'textarea',
|
|
123
|
+
rowspan: [
|
|
124
|
+
'td',
|
|
125
|
+
'th'
|
|
126
|
+
],
|
|
127
|
+
size: [
|
|
128
|
+
'input',
|
|
129
|
+
'select'
|
|
130
|
+
],
|
|
131
|
+
span: [
|
|
132
|
+
'col',
|
|
133
|
+
'colgroup'
|
|
134
|
+
],
|
|
135
|
+
src: [
|
|
136
|
+
'audio',
|
|
137
|
+
'embed',
|
|
138
|
+
'iframe',
|
|
139
|
+
'img',
|
|
140
|
+
'input',
|
|
141
|
+
'script',
|
|
142
|
+
'source',
|
|
143
|
+
'track',
|
|
144
|
+
'video'
|
|
145
|
+
],
|
|
146
|
+
start: 'ol',
|
|
147
|
+
tabindex: null,
|
|
148
|
+
type: [
|
|
149
|
+
'a',
|
|
150
|
+
'link',
|
|
151
|
+
'button',
|
|
152
|
+
'embed',
|
|
153
|
+
'object',
|
|
154
|
+
'script',
|
|
155
|
+
'source',
|
|
156
|
+
'style',
|
|
157
|
+
'input',
|
|
158
|
+
'menu',
|
|
159
|
+
'menuitem',
|
|
160
|
+
'ol'
|
|
161
|
+
],
|
|
162
|
+
value: [
|
|
163
|
+
'button',
|
|
164
|
+
'input',
|
|
165
|
+
'li'
|
|
166
|
+
],
|
|
167
|
+
width: [
|
|
168
|
+
'canvas',
|
|
169
|
+
'embed',
|
|
170
|
+
'iframe',
|
|
171
|
+
'img',
|
|
172
|
+
'input',
|
|
173
|
+
'object',
|
|
174
|
+
'video'
|
|
175
|
+
]
|
|
176
|
+
};
|
|
177
|
+
const mod = {
|
|
178
|
+
onAttrs () {
|
|
179
|
+
return (attrs, node)=>{
|
|
180
|
+
const newAttrs = {
|
|
181
|
+
...attrs
|
|
182
|
+
};
|
|
183
|
+
Object.entries(attrs).forEach(([attrName, attrValue])=>{
|
|
184
|
+
if (helpers_js.isEventHandler(attrName) || Object.hasOwnProperty.call(safeToRemoveAttrs, attrName) && (safeToRemoveAttrs[attrName] === null || typeof node.tag === 'string' && safeToRemoveAttrs[attrName].includes(node.tag))) {
|
|
185
|
+
if (typeof attrValue === 'string') {
|
|
186
|
+
if (attrValue === '' || attrValue.trim() === '') {
|
|
187
|
+
delete newAttrs[attrName];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
return newAttrs;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
exports.default = mod;
|