Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

RFC: Event handler return value will be ignored in 4.0.0 #387

Closed
leonsenft opened this issue May 15, 2017 · 1 comment
Closed

RFC: Event handler return value will be ignored in 4.0.0 #387

leonsenft opened this issue May 15, 2017 · 1 comment
Assignees
Milestone

Comments

@leonsenft
Copy link
Contributor

Angular currently supports cancelling an event's default behavior by returning false from an event handler. Unfortunately all event handlers must pay the cost of performing this check whether they return a bool or not. In 4.0.0 we're dropping support for this feature in favor of improving performance and generating less code.

For example, currently placing the following directive on a link will prevent navigation when clicked.

import 'package:angular2/angular2.dart';

@Directive(
  selector: 'inert',
  host: {
    '(click)': 'onClick()',
  },
)
class InertDirective {
  bool onClick() => false; // prevents 'click' event default behavior.
}

From 4.0.0 onward, explicit use of Event.preventDefault() will be required.

import 'dart:html';

import 'package:angular2/angular2.dart';

@Directive(
  selector: 'inert',
  host: {
    '(click)': r'onClick($event)',
  },
)
class InertDirective {
  void onClick(Event event) => event.preventDefault();
}
@leonsenft leonsenft added this to the V4 Beta milestone May 15, 2017
@leonsenft leonsenft self-assigned this May 15, 2017
matanlurey pushed a commit that referenced this issue May 18, 2017
…rDart 4.0.0

#387

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156232875
matanlurey pushed a commit that referenced this issue May 18, 2017
…rDart 4.0.0

#387

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156323322
matanlurey pushed a commit that referenced this issue May 18, 2017
…rDart 4.0.0

#387

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156232875
matanlurey pushed a commit that referenced this issue May 18, 2017
…rDart 4.0.0

#387

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156323322
matanlurey pushed a commit that referenced this issue May 24, 2017
matanlurey pushed a commit that referenced this issue May 24, 2017
@matanlurey
Copy link
Contributor

Closed by 00ac8dd. Woohoo!

Thanks @leonsenft!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants