Skip to content

Commit

Permalink
wrap CEReactions code into try-finally
Browse files Browse the repository at this point in the history
  • Loading branch information
pmdartus committed Nov 26, 2019
1 parent 251a03c commit 9c62d29
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 31 deletions.
68 changes: 39 additions & 29 deletions test/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,17 @@ const iface = {
});
// CEReactions pre steps
const creating = !target[impl][utils.supportsPropertyName](P);
if (creating) {
target[impl][utils.namedSetNew](P, namedValue);
} else {
target[impl][utils.namedSetExisting](P, namedValue);
try {
const creating = !target[impl][utils.supportsPropertyName](P);
if (creating) {
target[impl][utils.namedSetNew](P, namedValue);
} else {
target[impl][utils.namedSetExisting](P, namedValue);
}
} finally {
// CEReactions post steps
}
// CEReactions post steps
return true;
}
}
Expand Down Expand Up @@ -226,16 +227,17 @@ const iface = {
});
// CEReactions pre steps
const creating = !target[impl][utils.supportsPropertyName](P);
if (creating) {
target[impl][utils.namedSetNew](P, namedValue);
} else {
target[impl][utils.namedSetExisting](P, namedValue);
try {
const creating = !target[impl][utils.supportsPropertyName](P);
if (creating) {
target[impl][utils.namedSetNew](P, namedValue);
} else {
target[impl][utils.namedSetExisting](P, namedValue);
}
} finally {
// CEReactions post steps
}
// CEReactions post steps
return true;
}
return Reflect.defineProperty(target, P, desc);
Expand All @@ -248,11 +250,12 @@ const iface = {
if (target[impl][utils.supportsPropertyName](P) && !(P in target)) {
// CEReactions pre steps
target[impl][utils.namedDelete](P);
return true;
// CEReactions post steps
try {
target[impl][utils.namedDelete](P);
return true;
} finally {
// CEReactions post steps
}
}
return Reflect.deleteProperty(target, P);
Expand Down Expand Up @@ -282,10 +285,11 @@ const iface = {
}
// CEReactions pre steps
return this[impl].method();
// CEReactions post steps
try {
return this[impl].method();
} finally {
// CEReactions post steps
}
}
get attr() {
Expand All @@ -294,8 +298,11 @@ const iface = {
}
// CEReactions pre steps
return this[impl][\\"attr\\"];
// CEReactions post steps
try {
return this[impl][\\"attr\\"];
} finally {
// CEReactions post steps
}
}
set attr(V) {
Expand All @@ -308,8 +315,11 @@ const iface = {
});
// CEReactions pre steps
this[impl][\\"attr\\"] = V;
// CEReactions post steps
try {
this[impl][\\"attr\\"] = V;
} finally {
// CEReactions post steps
}
}
}
Object.defineProperties(CEReactions.prototype, {
Expand Down
7 changes: 5 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ beforeAll(() => {
processCEReactions(_, code) {
return `
// CEReactions pre steps
${code}
// CEReactions post steps
try {
${code}
} finally {
// CEReactions post steps
}
`;
},
processHTMLConstructor(_, code) {
Expand Down

0 comments on commit 9c62d29

Please sign in to comment.