Skip to content

Commit 236bde0

Browse files
committed
pat-inject: Minor code optimization: Consistently use nodeName over tagName.
nodeName returns for Elements the same value but also works on document fragments and other type of nodes.
1 parent 97efc57 commit 236bde0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/pat/inject/inject.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const inject = {
108108
}
109109
});
110110
// setup event handlers
111-
if (el?.tagName === "FORM") {
111+
if (el?.nodeName === "FORM") {
112112
log.debug("Initializing form with injection on", el);
113113
events.add_event_listener(
114114
el,
@@ -190,7 +190,7 @@ const inject = {
190190
const el = e.currentTarget;
191191
const $el = $(el);
192192
let cfgs = $el.data("pat-inject");
193-
if (el.tagName === "FORM" && e.type === "submit") {
193+
if (el.nodeName === "FORM" && e.type === "submit") {
194194
const form = el;
195195
const submitter = e.submitter;
196196

@@ -568,7 +568,7 @@ const inject = {
568568
sources$ &&
569569
sources$[sources$.length - 1] &&
570570
sources$[sources$.length - 1][0] &&
571-
sources$[sources$.length - 1][0].nodeName == "TITLE"
571+
sources$[sources$.length - 1][0].nodeName === "TITLE"
572572
) {
573573
title = sources$[sources$.length - 1];
574574
}
@@ -885,7 +885,7 @@ const inject = {
885885
.map(([tag, attr]) => `${tag}[${attr}]`)
886886
.join(", ");
887887
for (const el_ of page.querySelectorAll(rebase_selector)) {
888-
const attr = this._rebaseAttrs[el_.tagName.toLowerCase()];
888+
const attr = this._rebaseAttrs[el_.nodeName.toLowerCase()];
889889
let value = el_.getAttribute(attr);
890890

891891
if (

0 commit comments

Comments
 (0)