Skip to content

Commit 7a08899

Browse files
committed
PropertyBinding: Clean up state initialization
1 parent 2d6bee0 commit 7a08899

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/animation/PropertyBinding.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ class Composite {
9595

9696
}
9797

98+
// Note: This class uses a State pattern on a per-method basis:
99+
// 'bind' sets 'this.getValue' / 'setValue' and shadows the
100+
// prototype version of these methods with one that represents
101+
// the bound state. When the property is not found, the methods
102+
// become no-ops.
98103
class PropertyBinding {
99104

100105
constructor( rootNode, path, parsedPath ) {
@@ -106,6 +111,10 @@ class PropertyBinding {
106111

107112
this.rootNode = rootNode;
108113

114+
// initial state of these methods that calls 'bind'
115+
this.getValue = this._getValue_unbound;
116+
this.setValue = this._setValue_unbound;
117+
109118
}
110119

111120

@@ -388,20 +397,14 @@ class PropertyBinding {
388397

389398
}
390399

391-
getValue( targetArray, offset ) {
400+
_getValue_unbound( targetArray, offset ) {
392401

393402
this.bind();
394403
this.getValue( targetArray, offset );
395404

396-
// Note: This class uses a State pattern on a per-method basis:
397-
// 'bind' sets 'this.getValue' / 'setValue' and shadows the
398-
// prototype version of these methods with one that represents
399-
// the bound state. When the property is not found, the methods
400-
// become no-ops.
401-
402405
}
403406

404-
setValue( sourceArray, offset ) {
407+
_setValue_unbound( sourceArray, offset ) {
405408

406409
this.bind();
407410
this.setValue( sourceArray, offset );
@@ -705,10 +708,6 @@ Object.assign( PropertyBinding.prototype, {
705708
GetterByBindingType,
706709
SetterByBindingTypeAndVersioning,
707710

708-
// initial state of these methods that calls 'bind'
709-
_getValue_unbound: PropertyBinding.prototype.getValue,
710-
_setValue_unbound: PropertyBinding.prototype.setValue,
711-
712711
} );
713712

714713
export { PropertyBinding };

0 commit comments

Comments
 (0)