From de5ac6b7c62a0a002f9b468937b3556432b670c2 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 9 May 2018 14:25:55 +0200 Subject: [PATCH 1/3] Fix typing in ol/xml module --- src/ol/xml.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/xml.js b/src/ol/xml.js index 2acf238be3..fcf0057cc6 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -389,7 +389,7 @@ export function makeSequence(object, orderedKeys) { */ export function makeStructureNS(namespaceURIs, structure, opt_structureNS) { /** - * @type {Object.} + * @type {Object.} */ const structureNS = opt_structureNS !== undefined ? opt_structureNS : {}; let i, ii; From 05b11759b772f3250d0b9d0157f82a7113be2e2e Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 9 May 2018 14:34:49 +0200 Subject: [PATCH 2/3] Handle undefined 'this' in ol/xml --- src/ol/xml.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/xml.js b/src/ol/xml.js index fcf0057cc6..59dc21eae1 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -144,7 +144,7 @@ export function makeArrayExtender(valueReader, opt_this) { * @param {Array.<*>} objectStack Object stack. */ function(node, objectStack) { - const value = valueReader.call(opt_this, node, objectStack); + const value = valueReader.call(opt_this !== undefined ? opt_this : this, node, objectStack); if (value !== undefined) { const array = /** @type {Array.<*>} */ (objectStack[objectStack.length - 1]); extend(array, value); @@ -469,7 +469,7 @@ export function serialize( for (let i = 0; i < length; ++i) { value = values[i]; if (value !== undefined) { - node = nodeFactory.call(opt_this, value, objectStack, + node = nodeFactory.call(opt_this !== undefined ? opt_this : this, value, objectStack, opt_keys !== undefined ? opt_keys[i] : undefined); if (node !== undefined) { serializersNS[node.namespaceURI][node.localName] From 9c13e041e3e5170605f80ad2eaac45b43dbe19d6 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 9 May 2018 14:44:03 +0200 Subject: [PATCH 3/3] Add missing typecast in ol/xml --- src/ol/xml.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/xml.js b/src/ol/xml.js index 59dc21eae1..c9724840e9 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -171,7 +171,7 @@ export function makeArrayPusher(valueReader, opt_this) { function(node, objectStack) { const value = valueReader.call(opt_this !== undefined ? opt_this : this, node, objectStack); if (value !== undefined) { - const array = objectStack[objectStack.length - 1]; + const array = /** @type {Array.<*>} */ (objectStack[objectStack.length - 1]); array.push(value); } }); @@ -271,7 +271,7 @@ export function makeObjectPropertySetter(valueReader, opt_property, opt_this) { export function makeChildAppender(nodeWriter, opt_this) { return function(node, value, objectStack) { nodeWriter.call(opt_this !== undefined ? opt_this : this, node, value, objectStack); - const parent = objectStack[objectStack.length - 1]; + const parent = /** @type {module:ol/xml~NodeStackItem} */ (objectStack[objectStack.length - 1]); const parentNode = parent.node; parentNode.appendChild(node); }; @@ -329,7 +329,7 @@ export function makeSimpleNodeFactory(opt_nodeName, opt_namespaceURI) { * @return {Node} Node. */ function(value, objectStack, opt_nodeName) { - const context = objectStack[objectStack.length - 1]; + const context = /** @type {module:ol/xml~NodeStackItem} */ (objectStack[objectStack.length - 1]); const node = context.node; let nodeName = fixedNodeName; if (nodeName === undefined) {