Skip to content

Commit

Permalink
Changed function signature.
Browse files Browse the repository at this point in the history
  • Loading branch information
feuzeu committed May 19, 2024
1 parent 2b71005 commit f9d808b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/cmd/body.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
return true;
}

const xElt = dom.getInnerObject(target, attr);
const xElt = dom.getInnerObject(attr, target);
if (xElt !== null) {
xElt.node[xElt.attr] = value;
}
Expand Down Expand Up @@ -52,7 +52,7 @@
return true;
}

const xElt = dom.getInnerObject(target, attr);
const xElt = dom.getInnerObject(attr, target);
if (xElt !== null) {
xElt.node[xElt.attr] = xElt.node[xElt.attr] + value;
}
Expand Down Expand Up @@ -80,7 +80,7 @@
return true;
}

const xElt = dom.getInnerObject(target, attr);
const xElt = dom.getInnerObject(attr, target);
if (xElt !== null) {
xElt.node[xElt.attr] = value + xElt.node[xElt.attr];
}
Expand Down Expand Up @@ -120,7 +120,7 @@
*/
self.replace = ({ target, attr, search, replace }) => {
const sSearch = attr === 'innerHTML' ? dom.getBrowserHTML(search) : search;
const xElt = dom.getInnerObject(target, attr);
const xElt = dom.getInnerObject(attr, target);
if (xElt !== null) {
replaceText(xElt.node, xElt.attr, sSearch, replace);
}
Expand Down
12 changes: 6 additions & 6 deletions src/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,21 @@
* Given an element and an attribute with 0 or more dots,
* get the inner object and the corresponding attribute name.
*
* @param {object} xElement The outer element.
* @param {string} attribute The attribute name.
* @param {string} sAttrName The attribute name.
* @param {object=} xElement The outer element.
*
* @returns {object|null} The inner object and the attribute name in an object.
*/
self.getInnerObject = (xElement, attribute) => {
const aNames = attribute.split('.');
self.getInnerObject = (sAttrName, xElement = window) => {
const aNames = sAttrName.split('.');
// Get the last element in the array.
attribute = aNames.pop();
sAttrName = aNames.pop();
// Move to the inner object.
const nLength = aNames.length;
for (let i = 0; i < nLength && (xElement); i++) {
// The real name for the "css" object is "style".
xElement = xElement[aNames[i] === 'css' ? 'style' : aNames[i]];
}
return !xElement ? null : { node: xElement, attr: attribute };
return !xElement ? null : { node: xElement, attr: sAttrName };
};
})(jaxon.utils.dom, jaxon.utils.types, jaxon.config.baseDocument);

0 comments on commit f9d808b

Please sign in to comment.