Skip to content

Commit

Permalink
feat: add queryChildren on GomlNode
Browse files Browse the repository at this point in the history
fix: improved error message on component
  • Loading branch information
kyasbal committed Mar 25, 2017
1 parent 9557efe commit 6142057
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/Node/GomlNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ class GomlNode extends EEObject {
return array;
}

/**
* Query children from current node.
* @param {string} query [description]
* @return GomlNode[] [description]
*/
public queryChildren(query: string): GomlNode[] {
const nodes = this.element.querySelectorAll(query);
const array = new Array(nodes.length);
for (let i = 0; i < nodes.length; i++) {
array[i] = GomlNode.fromElement(nodes.item(i));
}
return array;
}

/**
* search from children node by name property.
* return all nodes has same name as given.
Expand Down Expand Up @@ -703,7 +717,11 @@ class GomlNode extends EEObject {
node: this,
component: targetComponent,
message: message,
handled: false
handled: false,
error: e,
toString: () => {
return `\n\n[MESSAGE STACK] at ${targetComponent}.${message.substr(1)}\nerror:${e}\n`;
}
};
this.emit("error", errorHandler);
if (!errorHandler.handled) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import __INTERFACE__4 from "./Node/IAttributeDeclaration";
import __INTERFACE__5 from "./Node/ITreeInitializedInfo";

var __VERSION__ = "0.14.0beta0";
var __VERSION__ = "0.14.4-beta7";
var __NAME__ = "grimoirejs";

import __MAIN__ from "./main";
Expand Down

0 comments on commit 6142057

Please sign in to comment.