Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(844)

Unified Diff: pkg/polymer/lib/src/build/linter.dart

Issue 303003003: Fix 19029: handle special case when on-handler is empty in polymer, add better (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/polymer/lib/src/build/script_compactor.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/build/linter.dart
diff --git a/pkg/polymer/lib/src/build/linter.dart b/pkg/polymer/lib/src/build/linter.dart
index c8e8a1854394ca67b2cefe1ec5380dd805a2b6b7..f0a231b2503bbe4c648112d939ca89cd1b67dcad 100644
--- a/pkg/polymer/lib/src/build/linter.dart
+++ b/pkg/polymer/lib/src/build/linter.dart
@@ -367,9 +367,12 @@ class _LinterVisitor extends TreeVisitor {
/// Validate event handlers are used correctly.
void _validateEventHandler(Element node, String name, String value) {
if (!name.startsWith('on-')) {
+ // TODO(sigmund): technically these are valid attribtues in HTML, so we
+ // might want to remove this warning, or only produce it if the value
+ // looks like a binding.
_logger.warning('Event handler "$name" will be interpreted as an inline'
' JavaScript event handler. Use the form '
- 'on-event-name="handlerName" if you want a Dart handler '
+ 'on-event-name="{{handlerName}}" if you want a Dart handler '
'that will automatically update the UI based on model changes.',
span: node.attributeSpans[name]);
return;
@@ -379,12 +382,17 @@ class _LinterVisitor extends TreeVisitor {
_logger.warning('Inline event handlers are only supported inside '
'declarations of <polymer-element>.',
span: node.attributeSpans[name]);
+ return;
}
- if (value.contains('(')) {
+
+ // Valid bindings have {{ }}, don't look like method calls foo(bar), and are
+ // non empty.
+ if (!value.startsWith("{{") || !value.endsWith("}}") || value.contains('(')
+ || value.substring(2, value.length - 2).trim() == '') {
_logger.warning('Invalid event handler body "$value". Declare a method '
'in your custom element "void handlerName(event, detail, target)" '
- 'and use the form $name="handlerName".',
+ 'and use the form $name="{{handlerName}}".',
span: node.attributeSpans[name]);
}
}
« no previous file with comments | « no previous file | pkg/polymer/lib/src/build/script_compactor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698