Skip to content

Instantly share code, notes, and snippets.

@think49
Created October 29, 2010 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save think49/653491 to your computer and use it in GitHub Desktop.
Save think49/653491 to your computer and use it in GitHub Desktop.
この gist は更新しても反映されない不具合があるため、http://gist.github.com/658057 に移行しました。
// ExtXPathEvaluator.js
function ExtXPathEvaluator () {
if (!(this instanceof ExtXPathEvaluator)) {
throw new Error(this + ' is not a object created by constructor');
}
return this;
}
(function () {
this.evaluate = function (domObject, expression /*, contextNode*/) {
var contextNode;
contextNode = arguments[2];
if (!contextNode) {
contextNode = domObject;
}
this.xPathResult = domObject.evaluate(expression, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
return this;
};
this.replace = function (property, searchValue, replaceValue) {
var xPathResult, node, i;
xPathResult = this.xPathResult;
for (i = xPathResult.snapshotLength - 1; i > -1; i--) {
node = xPathResult.snapshotItem(i);
node[property] = node[property].replace(searchValue, replaceValue);
}
return this;
};
this.forEach = function (callbackfn /*, thisArg*/) {
var xPathResult, thisArg, k, len, foo;
if (typeof callbackfn !== 'function') {
throw new TypeError(callbackfn + ' is not a function');
}
xPathResult = this.xPathResult;
if (arguments.length < 2) {
for (k = 0, len = xPathResult.snapshotLength; k < len; k++){
callbackfn(xPathResult.snapshotItem(k));
}
} else {
thisArg = arguments[1];
for (k = 0, len = xPathResult.snapshotLength; k < len; k++){
callbackfn.call(thisArg, xPathResult.snapshotItem(k));
}
}
return this;
};
}).call(ExtXPathEvaluator.prototype);
@think49
Copy link
Author

think49 commented Oct 29, 2010

この gist は更新しても反映されない不具合があります。
サポートに連絡したところ、「同不具合は修正されましたが、新しく gist を作り直すことでしか解決することはできない」との返答を得ました。
そのため、http://gist.github.com/658057 に移動しました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment