Skip to content

Commit fa07469

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 5c3c1aa commit fa07469

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,
@@ -192,7 +192,7 @@ const inject = {
192192
const el = e.currentTarget;
193193
const $el = $(el);
194194
let cfgs = $el.data("pat-inject");
195-
if (el.tagName === "FORM" && e.type === "submit") {
195+
if (el.nodeName === "FORM" && e.type === "submit") {
196196
const form = el;
197197
const submitter = e.submitter;
198198

@@ -570,7 +570,7 @@ const inject = {
570570
sources$ &&
571571
sources$[sources$.length - 1] &&
572572
sources$[sources$.length - 1][0] &&
573-
sources$[sources$.length - 1][0].nodeName == "TITLE"
573+
sources$[sources$.length - 1][0].nodeName === "TITLE"
574574
) {
575575
title = sources$[sources$.length - 1];
576576
}
@@ -882,7 +882,7 @@ const inject = {
882882
.map(([tag, attr]) => `${tag}[${attr}]`)
883883
.join(", ");
884884
for (const el_ of page.querySelectorAll(rebase_selector)) {
885-
const attr = this._rebaseAttrs[el_.tagName.toLowerCase()];
885+
const attr = this._rebaseAttrs[el_.nodeName.toLowerCase()];
886886
let value = el_.getAttribute(attr);
887887

888888
if (

0 commit comments

Comments
 (0)