Skip to content

Commit

Permalink
Update can-stache deps to latest major; reuse observation if reconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
bmomberger-bitovi committed Jan 22, 2020
1 parent 5f5cf9d commit 5d271f0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"@webcomponents/custom-elements": "^1.2.4",
"can-observable-array": "^1.0.6",
"can-observable-object": "^1.0.1",
"can-stache": "^4.17.21",
"can-stache-bindings": "^4.10.9",
"can-stache": "^5.1.1",
"can-stache-bindings": "^5.0.4",
"preact": "^8.5.3",
"preact-compat": "^3.19.0",
"prop-types": "^15.7.2",
Expand Down
10 changes: 7 additions & 3 deletions react-to-webcomponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ QUnit.test("works with nested properties of observable objects and arrays", func
render() {
return <React.Fragment>
<h1>
Hello, { this.props.name.first } { this.props.name.last }
Hello, { this.props.name.full }
</h1>
<h1>
I see you like { this.props.hobbies.join(" and ")}
Expand All @@ -169,9 +169,13 @@ QUnit.test("works with nested properties of observable objects and arrays", func
var fixture = document.getElementById("qunit-fixture");

var myWelcome = new MyWelcome();
myWelcome.name = new ObservableObject({
myWelcome.name = new (class extends ObservableObject {
get full() {
return this.first + ' ' + this.last;
}
})({
first: "Justin",
last: "Meyer"
last: "Meyer",
});
myWelcome.hobbies = new ObservableArray([
"basketball",
Expand Down
2 changes: 1 addition & 1 deletion react-to-webcomponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function(ReactComponent, React, ReactDOM) {
this[shouldRenderSymbol] = true;
// Also catch any sub-properties of observables which
// are read while rendering the React component.
this[observationSymbol] = new Observation(() => {
this[observationSymbol] = this[observationSymbol] || new Observation(() => {
this[renderSymbol]();
});
this[observationSymbol].on();
Expand Down

0 comments on commit 5d271f0

Please sign in to comment.