From a5bb4632e5ea0170040b560f8648e2688da3f1c8 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Tue, 4 Feb 2014 15:39:28 +0100 Subject: [PATCH] Add ol.xml.isDocument --- src/ol/xml.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/ol/xml.js b/src/ol/xml.js index 908b2e9516..6621186839 100644 --- a/src/ol/xml.js +++ b/src/ol/xml.js @@ -4,6 +4,7 @@ goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); goog.require('goog.object'); +goog.require('goog.userAgent'); /** @@ -48,6 +49,34 @@ ol.xml.getAllTextContent_ = function(node, normalizeWhitespace, accumulator) { }; +/** + * @param {?} value Value. + * @private + * @return {boolean} Is document. + */ +ol.xml.isDocument_ = function(value) { + return value instanceof Document; +}; + + +/** + * @param {?} value Value. + * @private + * @return {boolean} Is document. + */ +ol.xml.isDocumentIE_ = function(value) { + return goog.isObject(value) && value.nodeType == goog.dom.NodeType.DOCUMENT; +}; + + +/** + * @param {?} value Value. + * @return {boolean} Is document. + */ +ol.xml.isDocument = goog.userAgent.IE ? + ol.xml.isDocumentIE_ : ol.xml.isDocument_; + + /** * @param {string} xml XML. * @return {Document} Document.