targetj 1.0.27 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/SearchUtil.js +17 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "keywords": [
5
5
  "targetj"
6
6
  ],
package/src/SearchUtil.js CHANGED
@@ -91,6 +91,9 @@ SearchUtil.findByType = function (type) {
91
91
  var tmodel;
92
92
 
93
93
  function search(container) {
94
+
95
+ if (container.tmodel.type === type) return container;
96
+
94
97
  var children = container.getChildren();
95
98
  var found;
96
99
 
@@ -98,10 +101,10 @@ SearchUtil.findByType = function (type) {
98
101
 
99
102
  tmodel = children[i];
100
103
 
101
- if (tmodel && tmodel.type === type) {
102
- found = tmodel;
103
- } else if (tmodel.hasChildren()) {
104
+ if (tmodel.hasChildren()) {
104
105
  found = search(tmodel);
106
+ } else if (tmodel.type === type) {
107
+ found = tmodel;
105
108
  }
106
109
  }
107
110
 
@@ -123,6 +126,8 @@ SearchUtil.findByTarget = function (target) {
123
126
 
124
127
  function search(container) {
125
128
 
129
+ if (container.targets[target]) return container;
130
+
126
131
  var children = container.getChildren();
127
132
  var found;
128
133
 
@@ -130,10 +135,10 @@ SearchUtil.findByTarget = function (target) {
130
135
 
131
136
  tmodel = children[i];
132
137
 
133
- if (tmodel && tmodel.targets[target]) {
134
- found = tmodel;
135
- } else if (tmodel.hasChildren()) {
138
+ if (tmodel.hasChildren()) {
136
139
  found = search(tmodel);
140
+ } else if (tmodel.targets[target]) {
141
+ found = tmodel;
137
142
  }
138
143
  }
139
144
 
@@ -154,17 +159,19 @@ SearchUtil.find = function (oid) {
154
159
  var tmodel;
155
160
 
156
161
  function search(container) {
157
-
162
+
163
+ if (container.oid === oid) return container;
164
+
158
165
  var children = container.getChildren();
159
166
  var found;
160
167
 
161
168
  for (var i = 0; children && i < children.length && !found; i++) {
162
169
  tmodel = children[i];
163
170
 
164
- if (tmodel.oid === oid) {
165
- found = tmodel;
166
- } else if (tmodel.hasChildren()) {
171
+ if (tmodel.hasChildren()) {
167
172
  found = search(tmodel);
173
+ } else if (tmodel.oid === oid) {
174
+ found = tmodel;
168
175
  }
169
176
  }
170
177