Skip to content

Commit 0314fc7

Browse files
committed
do ignoredClasses with regex when needed in the future
1 parent 2b67150 commit 0314fc7

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

dist/browser/pangu.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export declare class BrowserPangu extends Pangu {
66
presentationalTags: RegExp;
77
spaceLikeTags: RegExp;
88
spaceSensitiveTags: RegExp;
9-
ignoredClasses: RegExp;
9+
ignoreClass: string;
1010
constructor();
1111
spacingNodeByXPath(xPathQuery: string, contextNode: Node): void;
1212
spacingNode(contextNode: Node): void;

dist/browser/pangu.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/browser/pangu.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/browser/pangu.umd.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/browser/pangu.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node/cli.cjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class BrowserPangu extends index.Pangu {
4444
__publicField(this, "presentationalTags");
4545
__publicField(this, "spaceLikeTags");
4646
__publicField(this, "spaceSensitiveTags");
47-
__publicField(this, "ignoredClasses");
47+
__publicField(this, "ignoreClass");
4848
this.isAutoSpacingPageExecuted = false;
4949
this.blockTags = /^(div|p|h1|h2|h3|h4|h5|h6)$/i;
5050
this.ignoredTags = /^(code|pre|script|style|textarea|iframe)$/i;
5151
this.presentationalTags = /^(b|code|del|em|i|s|strong|kbd)$/i;
5252
this.spaceLikeTags = /^(br|hr|i|img|pangu)$/i;
5353
this.spaceSensitiveTags = /^(a|del|pre|s|strike|u)$/i;
54-
this.ignoredClasses = /\bno-pangu-spacing\b/;
54+
this.ignoreClass = "no-pangu-spacing";
5555
}
5656
spacingNodeByXPath(xPathQuery, contextNode) {
5757
if (!(contextNode instanceof Node) || contextNode instanceof DocumentFragment) {
@@ -299,10 +299,10 @@ class BrowserPangu extends index.Pangu {
299299
return false;
300300
}
301301
hasIgnoredClasses(node) {
302-
if (node instanceof Element && this.ignoredClasses.test(node.className)) {
302+
if (node instanceof Element && node.classList.contains(this.ignoreClass)) {
303303
return true;
304304
}
305-
if (node.parentNode && node.parentNode instanceof Element && this.ignoredClasses.test(node.parentNode.className)) {
305+
if (node.parentNode && node.parentNode instanceof Element && node.parentNode.classList.contains(this.ignoreClass)) {
306306
return true;
307307
}
308308
return false;

dist/node/cli.cjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/browser/pangu.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class BrowserPangu extends Pangu {
4848
public presentationalTags: RegExp;
4949
public spaceLikeTags: RegExp;
5050
public spaceSensitiveTags: RegExp;
51-
public ignoredClasses: RegExp;
51+
public ignoreClass: string;
5252

5353
constructor() {
5454
super();
@@ -59,7 +59,7 @@ export class BrowserPangu extends Pangu {
5959
this.presentationalTags = /^(b|code|del|em|i|s|strong|kbd)$/i;
6060
this.spaceLikeTags = /^(br|hr|i|img|pangu)$/i;
6161
this.spaceSensitiveTags = /^(a|del|pre|s|strike|u)$/i;
62-
this.ignoredClasses = /\bno-pangu-spacing\b/;
62+
this.ignoreClass = 'no-pangu-spacing';
6363
}
6464

6565
public spacingNodeByXPath(xPathQuery: string, contextNode: Node) {
@@ -404,12 +404,12 @@ export class BrowserPangu extends Pangu {
404404

405405
protected hasIgnoredClasses(node: Node) {
406406
// Check the node itself if it's an element
407-
if (node instanceof Element && node.classList.contains('no-pangu-spacing')) {
407+
if (node instanceof Element && node.classList.contains(this.ignoreClass)) {
408408
return true;
409409
}
410410

411411
// Check the parent node (for text nodes)
412-
if (node.parentNode && node.parentNode instanceof Element && node.parentNode.classList.contains('no-pangu-spacing')) {
412+
if (node.parentNode && node.parentNode instanceof Element && node.parentNode.classList.contains(this.ignoreClass)) {
413413
return true;
414414
}
415415

0 commit comments

Comments
 (0)