Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
$unbind(flags) {
if (!(this.$state & 2 /* isBound */)) {
return;
}
// add isUnbinding flag
this.$state |= 64 /* isUnbinding */;
const sourceExpression = this.sourceExpression;
if (hasUnbind(sourceExpression)) {
sourceExpression.unbind(flags, this.$scope, this);
}
this.$scope = null;
this.handler.dispose();
this.handler = null;
// remove isBound and isUnbinding flags
this.$state &= ~(2 /* isBound */ | 64 /* isUnbinding */);
}
observeProperty(flags, obj, propertyName) {
$unbind(flags) {
if (!(this.$state & 4 /* isBound */)) {
return;
}
// add isUnbinding flag
this.$state |= 2 /* isUnbinding */;
const sourceExpression = this.sourceExpression;
if (hasUnbind(sourceExpression)) {
sourceExpression.unbind(flags, this.$scope, this.interceptor);
}
this.$scope = null;
this.handler.dispose();
this.handler = null;
// remove isBound and isUnbinding flags
this.$state &= ~(4 /* isBound */ | 2 /* isUnbinding */);
}
observeProperty(flags, obj, propertyName) {
$unbind(flags) {
if (!(this.$state & 4 /* isBound */)) {
return;
}
// add isUnbinding flag
this.$state |= 2 /* isUnbinding */;
// clear persistent flags
this.persistentFlags = 0 /* none */;
if (hasUnbind(this.sourceExpression)) {
this.sourceExpression.unbind(flags, this.$scope, this.interceptor);
}
this.$scope = null;
if (this.targetObserver.unbind) {
this.targetObserver.unbind(flags);
}
if (this.targetObserver.unsubscribe) {
this.targetObserver.unsubscribe(this.interceptor);
this.targetObserver[this.id] &= ~32 /* updateSourceExpression */;
}
this.interceptor.unobserve(true);
// remove isBound and isUnbinding flags
this.$state &= ~(4 /* isBound */ | 2 /* isUnbinding */);
}
connect(flags) {
public $unbind(flags: LifecycleFlags): void {
if (!(this.$state & State.isBound)) {
return;
}
// add isUnbinding flag
this.$state |= State.isUnbinding;
// clear persistent flags
this.persistentFlags = LifecycleFlags.none;
if (hasUnbind(this.sourceExpression)) {
this.sourceExpression.unbind(flags, this.$scope, this);
}
this.$scope = null!;
if ((this.targetObserver as IBindingTargetObserver).unbind) {
(this.targetObserver as IBindingTargetObserver).unbind!(flags);
}
if ((this.targetObserver as IBindingTargetObserver).unsubscribe) {
(this.targetObserver as IBindingTargetObserver).unsubscribe(this);
(this.targetObserver as IBindingTargetObserver & { [key: string]: number })[this.id] &= ~LifecycleFlags.updateSourceExpression;
}
this.unobserve(true);
// remove isBound and isUnbinding flags
this.$state &= ~(State.isBound | State.isUnbinding);
}
it('hasUnbind', function () {
expect(hasUnbind(new AccessThis() )).to.equal(false);
expect(hasUnbind(new AccessScope('') )).to.equal(false);
expect(hasUnbind(new ArrayLiteral([]) )).to.equal(false);
expect(hasUnbind(new ObjectLiteral([], []) )).to.equal(false);
expect(hasUnbind(new PrimitiveLiteral('') )).to.equal(false);
expect(hasUnbind(new Template([]) )).to.equal(false);
expect(hasUnbind(new Unary('!', e) )).to.equal(false);
expect(hasUnbind(new CallScope('!', []) )).to.equal(false);
expect(hasUnbind(new CallMember(e, '', []) )).to.equal(false);
expect(hasUnbind(new CallFunction(e, []) )).to.equal(false);
expect(hasUnbind(new AccessMember(e, '') )).to.equal(false);
expect(hasUnbind(new AccessKeyed(e, e) )).to.equal(false);
expect(hasUnbind(new TaggedTemplate([], [], e) )).to.equal(false);
expect(hasUnbind(new Binary('+', e, e) )).to.equal(false);
expect(hasUnbind(new Conditional(e, e, e) )).to.equal(false);
expect(hasUnbind(new Assign(e, e) )).to.equal(false);
expect(hasUnbind(new ValueConverter(e, '', []) )).to.equal(true);
expect(hasUnbind(new BindingBehavior(e, '', []) )).to.equal(true);
expect(hasUnbind(new HtmlLiteral([]) )).to.equal(false);
expect(hasUnbind(new ArrayBindingPattern([]) )).to.equal(false);
expect(hasUnbind(new ObjectBindingPattern([], []))).to.equal(false);
expect(hasUnbind(new BindingIdentifier('') )).to.equal(false);
expect(hasUnbind(new ForOfStatement(e, e) )).to.equal(true);
it('hasUnbind', function () {
expect(hasUnbind(new AccessThis() )).to.equal(false);
expect(hasUnbind(new AccessScope('') )).to.equal(false);
expect(hasUnbind(new ArrayLiteral([]) )).to.equal(false);
expect(hasUnbind(new ObjectLiteral([], []) )).to.equal(false);
expect(hasUnbind(new PrimitiveLiteral('') )).to.equal(false);
expect(hasUnbind(new Template([]) )).to.equal(false);
expect(hasUnbind(new Unary('!', e) )).to.equal(false);
expect(hasUnbind(new CallScope('!', []) )).to.equal(false);
expect(hasUnbind(new CallMember(e, '', []) )).to.equal(false);
expect(hasUnbind(new CallFunction(e, []) )).to.equal(false);
expect(hasUnbind(new AccessMember(e, '') )).to.equal(false);
expect(hasUnbind(new AccessKeyed(e, e) )).to.equal(false);
expect(hasUnbind(new TaggedTemplate([], [], e) )).to.equal(false);
expect(hasUnbind(new Binary('+', e, e) )).to.equal(false);
expect(hasUnbind(new Conditional(e, e, e) )).to.equal(false);
expect(hasUnbind(new Assign(e, e) )).to.equal(false);
expect(hasUnbind(new ValueConverter(e, '', []) )).to.equal(true);
expect(hasUnbind(new BindingBehavior(e, '', []) )).to.equal(true);
expect(hasUnbind(new HtmlLiteral([]) )).to.equal(false);
expect(hasUnbind(new ArrayBindingPattern([]) )).to.equal(false);
expect(hasUnbind(new ObjectBindingPattern([], []))).to.equal(false);
expect(hasUnbind(new BindingIdentifier('') )).to.equal(false);
expect(hasUnbind(new ForOfStatement(e, e) )).to.equal(true);
expect(hasUnbind(new Interpolation([]) )).to.equal(false);
});
it('hasUnbind', function () {
expect(hasUnbind(new AccessThis() )).to.equal(false);
expect(hasUnbind(new AccessScope('') )).to.equal(false);
expect(hasUnbind(new ArrayLiteral([]) )).to.equal(false);
expect(hasUnbind(new ObjectLiteral([], []) )).to.equal(false);
expect(hasUnbind(new PrimitiveLiteral('') )).to.equal(false);
expect(hasUnbind(new Template([]) )).to.equal(false);
expect(hasUnbind(new Unary('!', e) )).to.equal(false);
expect(hasUnbind(new CallScope('!', []) )).to.equal(false);
expect(hasUnbind(new CallMember(e, '', []) )).to.equal(false);
expect(hasUnbind(new CallFunction(e, []) )).to.equal(false);
expect(hasUnbind(new AccessMember(e, '') )).to.equal(false);
expect(hasUnbind(new AccessKeyed(e, e) )).to.equal(false);
expect(hasUnbind(new TaggedTemplate([], [], e) )).to.equal(false);
expect(hasUnbind(new Binary('+', e, e) )).to.equal(false);
expect(hasUnbind(new Conditional(e, e, e) )).to.equal(false);
expect(hasUnbind(new Assign(e, e) )).to.equal(false);
expect(hasUnbind(new ValueConverter(e, '', []) )).to.equal(true);
expect(hasUnbind(new BindingBehavior(e, '', []) )).to.equal(true);
expect(hasUnbind(new HtmlLiteral([]) )).to.equal(false);
expect(hasUnbind(new ArrayBindingPattern([]) )).to.equal(false);
expect(hasUnbind(new ObjectBindingPattern([], []))).to.equal(false);
expect(hasUnbind(new BindingIdentifier('') )).to.equal(false);
it('hasUnbind', function () {
expect(hasUnbind(new AccessThis() )).to.equal(false);
expect(hasUnbind(new AccessScope('') )).to.equal(false);
expect(hasUnbind(new ArrayLiteral([]) )).to.equal(false);
expect(hasUnbind(new ObjectLiteral([], []) )).to.equal(false);
expect(hasUnbind(new PrimitiveLiteral('') )).to.equal(false);
expect(hasUnbind(new Template([]) )).to.equal(false);
expect(hasUnbind(new Unary('!', e) )).to.equal(false);
expect(hasUnbind(new CallScope('!', []) )).to.equal(false);
expect(hasUnbind(new CallMember(e, '', []) )).to.equal(false);
expect(hasUnbind(new CallFunction(e, []) )).to.equal(false);
expect(hasUnbind(new AccessMember(e, '') )).to.equal(false);
expect(hasUnbind(new AccessKeyed(e, e) )).to.equal(false);
expect(hasUnbind(new TaggedTemplate([], [], e) )).to.equal(false);
expect(hasUnbind(new Binary('+', e, e) )).to.equal(false);
expect(hasUnbind(new Conditional(e, e, e) )).to.equal(false);
expect(hasUnbind(new Assign(e, e) )).to.equal(false);
expect(hasUnbind(new ValueConverter(e, '', []) )).to.equal(true);
expect(hasUnbind(new BindingBehavior(e, '', []) )).to.equal(true);
expect(hasUnbind(new HtmlLiteral([]) )).to.equal(false);
expect(hasUnbind(new ArrayBindingPattern([]) )).to.equal(false);
expect(hasUnbind(new ObjectBindingPattern([], []))).to.equal(false);
expect(hasUnbind(new BindingIdentifier('') )).to.equal(false);
expect(hasUnbind(new ForOfStatement(e, e) )).to.equal(true);
expect(hasUnbind(new Interpolation([]) )).to.equal(false);
});
expect(hasUnbind(new CallMember(e, '', []) )).to.equal(false);
expect(hasUnbind(new CallFunction(e, []) )).to.equal(false);
expect(hasUnbind(new AccessMember(e, '') )).to.equal(false);
expect(hasUnbind(new AccessKeyed(e, e) )).to.equal(false);
expect(hasUnbind(new TaggedTemplate([], [], e) )).to.equal(false);
expect(hasUnbind(new Binary('+', e, e) )).to.equal(false);
expect(hasUnbind(new Conditional(e, e, e) )).to.equal(false);
expect(hasUnbind(new Assign(e, e) )).to.equal(false);
expect(hasUnbind(new ValueConverter(e, '', []) )).to.equal(true);
expect(hasUnbind(new BindingBehavior(e, '', []) )).to.equal(true);
expect(hasUnbind(new HtmlLiteral([]) )).to.equal(false);
expect(hasUnbind(new ArrayBindingPattern([]) )).to.equal(false);
expect(hasUnbind(new ObjectBindingPattern([], []))).to.equal(false);
expect(hasUnbind(new BindingIdentifier('') )).to.equal(false);
expect(hasUnbind(new ForOfStatement(e, e) )).to.equal(true);
expect(hasUnbind(new Interpolation([]) )).to.equal(false);
});
expect(hasUnbind(new PrimitiveLiteral('') )).to.equal(false);
expect(hasUnbind(new Template([]) )).to.equal(false);
expect(hasUnbind(new Unary('!', e) )).to.equal(false);
expect(hasUnbind(new CallScope('!', []) )).to.equal(false);
expect(hasUnbind(new CallMember(e, '', []) )).to.equal(false);
expect(hasUnbind(new CallFunction(e, []) )).to.equal(false);
expect(hasUnbind(new AccessMember(e, '') )).to.equal(false);
expect(hasUnbind(new AccessKeyed(e, e) )).to.equal(false);
expect(hasUnbind(new TaggedTemplate([], [], e) )).to.equal(false);
expect(hasUnbind(new Binary('+', e, e) )).to.equal(false);
expect(hasUnbind(new Conditional(e, e, e) )).to.equal(false);
expect(hasUnbind(new Assign(e, e) )).to.equal(false);
expect(hasUnbind(new ValueConverter(e, '', []) )).to.equal(true);
expect(hasUnbind(new BindingBehavior(e, '', []) )).to.equal(true);
expect(hasUnbind(new HtmlLiteral([]) )).to.equal(false);
expect(hasUnbind(new ArrayBindingPattern([]) )).to.equal(false);
expect(hasUnbind(new ObjectBindingPattern([], []))).to.equal(false);
expect(hasUnbind(new BindingIdentifier('') )).to.equal(false);
expect(hasUnbind(new ForOfStatement(e, e) )).to.equal(true);
expect(hasUnbind(new Interpolation([]) )).to.equal(false);
});