-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ec6c02
commit b7f3fcc
Showing
1 changed file
with
26 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,45 @@ | ||
/** | ||
* @file XML XPath Concat object | ||
* @file XML XPath Concat operator | ||
* @since 1.0.1 | ||
*/ | ||
/*#ifndef(UMD)*/ | ||
"use strict"; | ||
/*global _gpfErrorDeclare*/ // Declare new gpf.Error names | ||
/*global _gpfIgnore*/ | ||
/*global _gpfDefine*/ | ||
/*global _gpfXmlXPathBase*/ | ||
/*exported _gpfXmlXPathConcat*/ | ||
/*exported _gpfXmlXpathConcatNodes*/ // Returns a list of unique nodes | ||
/*exported _gpfXmlXPathConcat*/ // gpf.xml.xpath.Concat | ||
/*#endif*/ | ||
|
||
/** | ||
* Concat the node lists to ensure the result contain only unique nodes | ||
* @param {gpf.interfaces.IXmlNodeSyncAdapter[]} currentNodes List of nodes to concatenate with | ||
* @param {gpf.interfaces.IXmlNodeSyncAdapter[]} newNodes List of nodes to add in the currentNodes list | ||
* @return {gpf.interfaces.IXmlNodeSyncAdapter[]} List of unique nodes | ||
*/ | ||
function _gpfXmlXpathConcatNodes (currentNodes, newNodes) { | ||
return currentNodes.concat(newNodes.filter(function (node) { | ||
return !curretNodes.includes(node); | ||
})); | ||
} | ||
|
||
/** | ||
* Implementation of the | operator | ||
* | ||
* @class gpf.xml.xpath.Concat | ||
* @extend gpf.xml.xpath.Base | ||
* @since 1.0.1 | ||
*/ | ||
var _gpfXmlXPathConcat = _gpfDefine({ | ||
$class: "gpf.xml.xpath.Concat", | ||
$extend: _gpfXmlXPathBase, | ||
|
||
_xpath: [], | ||
$extend: _GpfXmlXPathBase, | ||
|
||
/** | ||
* @inheritdoc | ||
* @since 1.0.1 | ||
*/ | ||
select: function (contextNode, namespaces) { | ||
return this._xpath.reduce(function (nodes, xpath) { | ||
nodes = nodes.concat(xpath.evaluate(contextNode, namespaces)); | ||
execute: function (contextNode, namespaces) { | ||
return this._children.reduce(function (nodes, xpath) { | ||
return _gpfXmlXpathConcatNodes(nodes, xpath.execute(contextNode, namespaces)); | ||
}, []); | ||
}, | ||
|
||
/** | ||
* Implementation of the | operator | ||
* | ||
* @class gpf.xml.xpath.Concat | ||
* @since 1.0.1 | ||
*/ | ||
constructor: function () { | ||
this._xpath = []; | ||
} | ||
}); |