Skip to content

Commit

Permalink
Merge pull request #36 from symbiotejs/fix-prop-binding-race
Browse files Browse the repository at this point in the history
fix: *prop binding race
  • Loading branch information
foxeyes authored Jul 8, 2022
2 parents f9c6350 + abccd2d commit 54609cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion core/BaseComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,15 @@ export class BaseComponent extends HTMLElement {
*/
sub(prop, handler) {
let parsed = BaseComponent.__parseProp(/** @type {string} */ (prop), this);
this.allSubs.add(parsed.ctx.sub(parsed.name, handler));
// @ts-ignore
if (!parsed.ctx.has(prop)) {
// Avoid *prop binding race:
window.setTimeout(() => {
this.allSubs.add(parsed.ctx.sub(parsed.name, handler));
});
} else {
this.allSubs.add(parsed.ctx.sub(parsed.name, handler));
}
}

/** @param {String} prop */
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.8.6",
"version": "1.8.7",
"description": "Symbiote.js",
"author": "[email protected]",
"license": "MIT",
Expand Down

0 comments on commit 54609cf

Please sign in to comment.