Skip to content

Commit

Permalink
Improve naming and use ++
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Mar 2, 2024
1 parent 50e0377 commit 251ed01
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
31 changes: 15 additions & 16 deletions dist/morphlex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 9 additions & 11 deletions src/morphlex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,13 @@ class Morph {
}

morph(node: ChildNode, reference: ChildNode): void {
const readonlyReference = reference as ReadonlyNode<ChildNode>;

if (isParentNode(node) && isParentNode(readonlyReference)) {
if (isParentNode(node) && isParentNode(reference)) {
this.#mapIdSets(node);
this.#mapIdSets(readonlyReference);
this.#mapIdSets(reference);
this.#mapSensivity(node);
}

this.#morphNode(node, readonlyReference);
this.#morphNode(node, reference);
}

#mapSensivity(node: ReadonlyNode<ParentNode>): void {
Expand All @@ -116,16 +114,16 @@ class Morph {
let sensivity = 0;

if (isInput(sensitiveElement) || isTextArea(sensitiveElement)) {
sensivity += 1;
sensivity++;

if (sensitiveElement.value !== sensitiveElement.defaultValue) sensivity += 1;
if (sensitiveElement === document.activeElement) sensivity += 1;
if (sensitiveElement.value !== sensitiveElement.defaultValue) sensivity++;
if (sensitiveElement === document.activeElement) sensivity++;
} else {
sensivity += 3;

if (isMedia(sensitiveElement) && !sensitiveElement.ended) {
if (!sensitiveElement.paused) sensivity += 1;
if (sensitiveElement.currentTime > 0) sensivity += 1;
if (!sensitiveElement.paused) sensivity++;
if (sensitiveElement.currentTime > 0) sensivity++;
}
}

Expand Down Expand Up @@ -238,7 +236,7 @@ class Morph {

for (let i = 0; i < refChildNodes.length; i++) {
const child = childNodes[i] as ChildNode | null;
const refChild = refChildNodes[i]; //as ReadonlyNode<ChildNode> | null;
const refChild = refChildNodes[i] as ReadonlyNode<ChildNode> | null;

if (child && refChild) {
if (isElement(child) && isElement(refChild)) this.#morphChildElement(child, refChild, element);
Expand Down

0 comments on commit 251ed01

Please sign in to comment.