Remove ol.xml.getLocalName workaround for IE

This property is available for IE >= 9
This commit is contained in:
Frederic Junod
2016-03-02 12:20:57 +01:00
parent 750a01aa80
commit b87a912ecc
4 changed files with 7 additions and 42 deletions

View File

@@ -111,7 +111,7 @@ ol.format.GMLBase.ONLY_WHITESPACE_RE_ = /^[\s\xa0]*$/;
ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) { ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT, goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT,
'node.nodeType should be ELEMENT'); 'node.nodeType should be ELEMENT');
var localName = ol.xml.getLocalName(node); var localName = node.localName;
var features; var features;
if (localName == 'FeatureCollection') { if (localName == 'FeatureCollection') {
if (node.namespaceURI === 'http://www.opengis.net/wfs') { if (node.namespaceURI === 'http://www.opengis.net/wfs') {
@@ -219,7 +219,7 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) {
ol.xml.getAttributeNS(node, ol.format.GMLBase.GMLNS, 'id'); ol.xml.getAttributeNS(node, ol.format.GMLBase.GMLNS, 'id');
var values = {}, geometryName; var values = {}, geometryName;
for (n = node.firstElementChild; n; n = n.nextElementSibling) { for (n = node.firstElementChild; n; n = n.nextElementSibling) {
var localName = ol.xml.getLocalName(n); var localName = n.localName;
// Assume attribute elements have one child node and that the child // Assume attribute elements have one child node and that the child
// is a text or CDATA node (to be treated as text). // is a text or CDATA node (to be treated as text).
// Otherwise assume it is a geometry node. // Otherwise assume it is a geometry node.

View File

@@ -1745,7 +1745,7 @@ ol.format.KML.prototype.getExtensions = function() {
ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) { ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) {
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT, goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT,
'node.nodeType should be ELEMENT'); 'node.nodeType should be ELEMENT');
var localName = ol.xml.getLocalName(node); var localName = node.localName;
goog.asserts.assert(localName == 'Document' || localName == 'Folder', goog.asserts.assert(localName == 'Document' || localName == 'Folder',
'localName should be Document or Folder'); 'localName should be Document or Folder');
// FIXME use scope somehow // FIXME use scope somehow
@@ -1923,7 +1923,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
return []; return [];
} }
var features; var features;
var localName = ol.xml.getLocalName(node); var localName = node.localName;
if (localName == 'Document' || localName == 'Folder') { if (localName == 'Document' || localName == 'Folder') {
features = this.readDocumentOrFolder_( features = this.readDocumentOrFolder_(
node, [this.getReadOptions(node, opt_options)]); node, [this.getReadOptions(node, opt_options)]);
@@ -2009,7 +2009,7 @@ ol.format.KML.prototype.readNameFromNode = function(node) {
} }
} }
for (n = node.firstElementChild; n; n = n.nextElementSibling) { for (n = node.firstElementChild; n; n = n.nextElementSibling) {
var localName = ol.xml.getLocalName(n); var localName = n.localName;
if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) &&
(localName == 'Document' || (localName == 'Document' ||
localName == 'Folder' || localName == 'Folder' ||
@@ -2080,7 +2080,7 @@ ol.format.KML.prototype.readNetworkLinksFromNode = function(node) {
} }
} }
for (n = node.firstElementChild; n; n = n.nextElementSibling) { for (n = node.firstElementChild; n; n = n.nextElementSibling) {
var localName = ol.xml.getLocalName(n); var localName = n.localName;
if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) &&
(localName == 'Document' || (localName == 'Document' ||
localName == 'Folder' || localName == 'Folder' ||

View File

@@ -75,7 +75,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ = function(node, objectStack
node.setAttribute('namespaceURI', this.featureNS_); node.setAttribute('namespaceURI', this.featureNS_);
goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT, goog.asserts.assert(node.nodeType == goog.dom.NodeType.ELEMENT,
'node.nodeType should be ELEMENT'); 'node.nodeType should be ELEMENT');
var localName = ol.xml.getLocalName(node); var localName = node.localName;
/** @type {Array.<ol.Feature>} */ /** @type {Array.<ol.Feature>} */
var features = []; var features = [];
if (node.childNodes.length === 0) { if (node.childNodes.length === 0) {

View File

@@ -114,41 +114,6 @@ ol.xml.getAllTextContent_ = function(node, normalizeWhitespace, accumulator) {
}; };
/**
* @param {Node} node Node.
* @private
* @return {string} Local name.
*/
ol.xml.getLocalName_ = function(node) {
return node.localName;
};
/**
* @param {Node} node Node.
* @private
* @return {string} Local name.
*/
ol.xml.getLocalNameIE_ = function(node) {
var localName = node.localName;
if (localName !== undefined) {
return localName;
}
var baseName = node.baseName;
goog.asserts.assert(baseName,
'Failed to get localName/baseName of node %s', node);
return baseName;
};
/**
* @param {Node} node Node.
* @return {string} Local name.
*/
ol.xml.getLocalName = goog.userAgent.IE ?
ol.xml.getLocalNameIE_ : ol.xml.getLocalName_;
/** /**
* @param {?} value Value. * @param {?} value Value.
* @private * @private