Skip to content

Commit

Permalink
fix(dom): slightly faster IsolateModule
Browse files Browse the repository at this point in the history
Avoid try catch in a while loop

ISSUES CLOSED: #383
  • Loading branch information
staltz committed Aug 25, 2016
1 parent 3cd5c90 commit 0126d2e
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions dom/src/isolateModule.ts
Expand Up @@ -21,16 +21,10 @@ export class IsolateModule {

isIsolatedElement(elm: Element): string | boolean {
let iterator = this.isolatedElements.entries();
let hasNext = true;
while (hasNext) {
try {
const result = iterator.next();
const [scope, element] = result.value;
if (elm === element) {
return scope;
}
} catch (err) {
hasNext = false;
for (let result = iterator.next(); !!result.value; result = iterator.next()) {
const [scope, element] = result.value;
if (elm === element) {
return scope;
}
}
return false;
Expand Down

0 comments on commit 0126d2e

Please sign in to comment.