aboutsummaryrefslogtreecommitdiff
path: root/lib/xmlreader.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-08-04 21:48:04 +0100
committerMichael Williamson <mike@zwobble.org>2015-08-04 21:50:41 +0100
commit91933a7a595e05ef7b860fa0223d2fac16c81c80 (patch)
tree7b7db4fc48970d3dfc5dd5964c92a7c8da506cbb /lib/xmlreader.js
parent2fcfbd4b3832ec6a6495bc08a2b97fa077c2f380 (diff)
Handle numbering properties without w:ilvl or w:numId
Diffstat (limited to 'lib/xmlreader.js')
-rw-r--r--lib/xmlreader.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/xmlreader.js b/lib/xmlreader.js
index f219d2b..551366f 100644
--- a/lib/xmlreader.js
+++ b/lib/xmlreader.js
@@ -85,6 +85,16 @@ function mapObject(input, valueFunc, keyFunc) {
}, {});
}
+var emptyElement = {
+ first: function() {
+ return null;
+ },
+ firstOrEmpty: function() {
+ return emptyElement;
+ },
+ attributes: {}
+};
+
function Element(name, attributes, children) {
this.type = "element";
this.name = name;
@@ -98,6 +108,10 @@ Element.prototype.first = function(name) {
});
};
+Element.prototype.firstOrEmpty = function(name) {
+ return this.first(name) || emptyElement;
+};
+
Element.prototype.getElementsByTagName = function(name) {
var elements = _.filter(this.children, function(child) {
return child.name == name;