Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(animations): allow @.disabled property to work without an expression #18713

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/compiler/src/template_parser/binding_parser.ts
Expand Up @@ -219,7 +219,7 @@ export class BindingParser {
// This will occur when a @trigger is not paired with an expression.
// For animations it is valid to not have an expression since */void
// states will be applied by angular when the element is attached/detached
const ast = this._parseBinding(expression || 'null', false, sourceSpan);
const ast = this._parseBinding(expression || 'undefined', false, sourceSpan);
targetMatchableAttrs.push([name, ast.source !]);
targetProps.push(new BoundProperty(name, ast, BoundPropertyType.ANIMATION, sourceSpan));
}
Expand Down
37 changes: 37 additions & 0 deletions packages/core/test/animation/animation_integration_spec.ts
Expand Up @@ -2691,6 +2691,43 @@ export function main() {
fixture.detectChanges();
expect(getLog().length).toEqual(1);
});

it('should treat the property as true when the expression is missing', () => {
@Component({
selector: 'parent-cmp',
animations: [
trigger(
'myAnimation',
[
transition(
'* => go',
[
style({opacity: 0}),
animate(500, style({opacity: 1})),
]),
]),
],
template: `
<div @.disabled>
<div [@myAnimation]="exp"></div>
</div>
`
})
class Cmp {
exp = '';
}

TestBed.configureTestingModule({declarations: [Cmp]});

const fixture = TestBed.createComponent(Cmp);
const cmp = fixture.componentInstance;
fixture.detectChanges();
resetLog();

cmp.exp = 'go';
fixture.detectChanges();
expect(getLog().length).toEqual(0);
});
});
});

Expand Down
Expand Up @@ -206,7 +206,8 @@ export class AnimationRenderer extends BaseAnimationRenderer implements Renderer
setProperty(el: any, name: string, value: any): void {
if (name.charAt(0) == ANIMATION_PREFIX) {
if (name.charAt(1) == '.' && name == DISABLE_ANIMATIONS_FLAG) {
this.disableAnimations(el, !!value);
value = value === undefined ? true : !!value;
this.disableAnimations(el, value as boolean);
} else {
this.engine.process(this.namespaceId, el, name.substr(1), value);
}
Expand Down