Skip to content

Commit

Permalink
remove global
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Apr 7, 2024
1 parent 4be33c7 commit 1fd2543
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/tiappxml.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const xml = appc.xml;
const __ = appc.i18n(__dirname).__;

const defaultDOMParserArgs = { errorHandler: function () {} };
let targetPlatform;
module.exports = tiapp;

function toXml(dom, parent, name, value) {
Expand Down Expand Up @@ -390,7 +389,7 @@ function toXml(dom, parent, name, value) {
node.appendChild(dom.createTextNode('\r\n' + new Array(2).join('\t')));
}

function toJS(obj, doc) {
function toJS(obj, doc, targetPlatform) {
var node = doc.firstChild;
while (node) {
if (node.nodeType === xml.ELEMENT_NODE) {
Expand Down Expand Up @@ -863,22 +862,21 @@ function toJS(obj, doc) {
}
}

function tiapp(filename, platform = '') {
targetPlatform = platform;
function tiapp(filename, platform) {

Object.defineProperty(this, 'load', {
value: function (file) {
if (!fs.existsSync(file)) {
throw new Error(__('tiapp.xml file does not exist'));
}
toJS(this, (new DOMParser(defaultDOMParserArgs).parseFromString(fs.readFileSync(file).toString(), 'text/xml')).documentElement);
toJS(this, (new DOMParser(defaultDOMParserArgs).parseFromString(fs.readFileSync(file).toString(), 'text/xml')).documentElement, platform);
return this;
}
});

Object.defineProperty(this, 'parse', {
value: function (str) {
toJS(this, (new DOMParser(defaultDOMParserArgs).parseFromString(str, 'text/xml')).documentElement);
toJS(this, (new DOMParser(defaultDOMParserArgs).parseFromString(str, 'text/xml')).documentElement, platform);
return this;
}
});
Expand Down

0 comments on commit 1fd2543

Please sign in to comment.