Skip to content

Commit

Permalink
2.12 fixes #25
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-markeev committed Oct 21, 2019
1 parent 137bf71 commit cad98c5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 41 deletions.
10 changes: 6 additions & 4 deletions dist/camljs.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,11 @@ var CamlBuilder = /** @class */ (function () {
case ModifyType.Replace:
return new FieldExpression(builder);
case ModifyType.AppendAnd:
var pos = builder.tree.length;
builder.WriteStart("And");
builder.unclosedTags++;
builder.tree = builder.tree.concat(whereBuilder.tree);
return new FieldExpression(builder);
case ModifyType.AppendOr:
var pos = builder.tree.length;
builder.WriteStart("Or");
builder.unclosedTags++;
builder.tree = builder.tree.concat(whereBuilder.tree);
Expand All @@ -388,7 +386,11 @@ var CamlBuilder = /** @class */ (function () {
};
RawQueryInternal.prototype.getXmlDocument = function (xml) {
var xmlDoc;
if (window["DOMParser"]) {
if (typeof window === "undefined") {
var XMLDOM = require('xmldom').DOMParser;
xmlDoc = new XMLDOM().parseFromString(this.xml, "text/xml");
}
else if (window["DOMParser"]) {
var parser = new DOMParser();
xmlDoc = parser.parseFromString(this.xml, "text/xml");
}
Expand Down Expand Up @@ -1348,5 +1350,5 @@ var CamlBuilder = /** @class */ (function () {
module.exports = CamlBuilder;

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}]},{},[1])(1)
},{"xmldom":"xmldom"}]},{},[1])(1)
});
7 changes: 4 additions & 3 deletions lib/camljs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -761,13 +761,11 @@ module CamlBuilder {
case ModifyType.Replace:
return new FieldExpression(builder);
case ModifyType.AppendAnd:
var pos = builder.tree.length;
builder.WriteStart("And");
builder.unclosedTags++;
builder.tree = builder.tree.concat(whereBuilder.tree);
return new FieldExpression(builder);
case ModifyType.AppendOr:
var pos = builder.tree.length;
builder.WriteStart("Or");
builder.unclosedTags++;
builder.tree = builder.tree.concat(whereBuilder.tree);
Expand All @@ -779,7 +777,10 @@ module CamlBuilder {

private getXmlDocument(xml: string): Document {
var xmlDoc: Document;
if (window["DOMParser"]) {
if (typeof window === "undefined") {
var XMLDOM = require('xmldom').DOMParser;
xmlDoc = new XMLDOM().parseFromString(this.xml, "text/xml");
} else if (window["DOMParser"]) {
var parser = new DOMParser();
xmlDoc = parser.parseFromString(this.xml, "text/xml");
}
Expand Down
72 changes: 42 additions & 30 deletions package-lock.json

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

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camljs",
"version": "2.11.0",
"version": "2.12.0",
"description": "Library for creating SharePoint CAML queries client-side. For JSOM, REST or SPServices.",
"main": "dist/camljs.js",
"types": "dist/camljs.d.ts",
Expand All @@ -9,9 +9,9 @@
"test": "tests"
},
"scripts": {
"build": "tsc && browserify lib/camljs.js -s CamlBuilder -o dist/camljs.js && tsc --declaration lib/camljs.ts --emitDeclarationOnly --outDir dist/",
"build": "tsc && browserify lib/camljs.js -x xmldom -s CamlBuilder -o dist/camljs.js && tsc --declaration lib/camljs.ts --emitDeclarationOnly --outDir dist/",
"test-common": "npm run build && tsc tests/Tests.ts --target es6 --module commonjs",
"test-html": "npm run test-common && browserify tests/Tests.js -s Tests -o tests/Tests.bundle.js",
"test-html": "npm run test-common && browserify tests/Tests.js -x xmldom -s Tests -o tests/Tests.bundle.js",
"test": "npm run test-common && node tests/index.js",
"clean": "del tests\\Tests.js && del tests\\Tests.bundle.js && del dist\\*.* /Q"
},
Expand Down Expand Up @@ -40,5 +40,8 @@
"sinon": "^4.5.0",
"ts-unit": "^1.0.1",
"typescript": "^2.8.1"
},
"dependencies": {
"xmldom": "^0.1.27"
}
}
2 changes: 1 addition & 1 deletion tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h2>Errors</h2>
p.removed ? "<del>" + encodeHtml(p.value) + "</del>" :
encodeHtml(p.value)); }, "") + "</pre>";
} else
html = err.message;
html = e.message;
return '<li>' + e.funcName + ": " + html + '</li>';
}).join("")}
</ul>
Expand Down

0 comments on commit cad98c5

Please sign in to comment.