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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Logic to validate that developers are correctly using Polymer constructs. 5 /// Logic to validate that developers are correctly using Polymer constructs.
6 /// This is mainly used to produce warnings for feedback in the editor. 6 /// This is mainly used to produce warnings for feedback in the editor.
7 library polymer.src.build.linter; 7 library polymer.src.build.linter;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 10
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 'dashes such as "$name". Use "$newName" or "${newName.toLowerCase()}" ' 360 'dashes such as "$name". Use "$newName" or "${newName.toLowerCase()}" '
361 'instead (both forms are equivalent in HTML).', span: span); 361 'instead (both forms are equivalent in HTML).', span: span);
362 return false; 362 return false;
363 } 363 }
364 return true; 364 return true;
365 } 365 }
366 366
367 /// Validate event handlers are used correctly. 367 /// Validate event handlers are used correctly.
368 void _validateEventHandler(Element node, String name, String value) { 368 void _validateEventHandler(Element node, String name, String value) {
369 if (!name.startsWith('on-')) { 369 if (!name.startsWith('on-')) {
370 _logger.warning('Event handler "$name" will be interpreted as an inline' 370 _logger.warning('Event handler "$name" will be interpreted as an inline'
Jennifer Messerly 2014/05/29 00:27:42 hmmm. at some point we might consider loosening th
Siggi Cherem (dart-lang) 2014/05/29 01:04:21 yeah, good point. Added TODO for now.
371 ' JavaScript event handler. Use the form ' 371 ' JavaScript event handler. Use the form '
372 'on-event-name="handlerName" if you want a Dart handler ' 372 'on-event-name="{{handlerName}}" if you want a Dart handler '
373 'that will automatically update the UI based on model changes.', 373 'that will automatically update the UI based on model changes.',
374 span: node.attributeSpans[name]); 374 span: node.attributeSpans[name]);
375 return; 375 return;
376 } 376 }
377 377
378 if (!_inPolymerElement) { 378 if (!_inPolymerElement) {
379 _logger.warning('Inline event handlers are only supported inside ' 379 _logger.warning('Inline event handlers are only supported inside '
380 'declarations of <polymer-element>.', 380 'declarations of <polymer-element>.',
381 span: node.attributeSpans[name]); 381 span: node.attributeSpans[name]);
382 } 382 }
383 383
384 if (value.contains('(')) { 384 if (value == '' || value == "{{}}" || value.contains('(')) {
Jennifer Messerly 2014/05/29 00:27:42 hmmm, not sure about this one ... any reason to s
Siggi Cherem (dart-lang) 2014/05/29 01:04:21 Good point. Done.
385 _logger.warning('Invalid event handler body "$value". Declare a method ' 385 _logger.warning('Invalid event handler body "$value". Declare a method '
386 'in your custom element "void handlerName(event, detail, target)" ' 386 'in your custom element "void handlerName(event, detail, target)" '
387 'and use the form $name="handlerName".', 387 'and use the form $name="{{handlerName}}".',
Jennifer Messerly 2014/05/29 00:27:42 nice catch!
388 span: node.attributeSpans[name]); 388 span: node.attributeSpans[name]);
389 } 389 }
390 } 390 }
391 } 391 }
392 392
393 const String ONLY_ONE_TAG = 393 const String ONLY_ONE_TAG =
394 'Only one "application/dart" script tag per document is allowed.'; 394 'Only one "application/dart" script tag per document is allowed.';
395 395
396 const String USE_POLYMER_HTML = 396 const String USE_POLYMER_HTML =
397 'Besides the initPolymer invocation, to run a polymer application you need ' 397 'Besides the initPolymer invocation, to run a polymer application you need '
398 'to include the following HTML import: ' 398 'to include the following HTML import: '
399 '<link rel="import" href="packages/polymer/polymer.html">. This will ' 399 '<link rel="import" href="packages/polymer/polymer.html">. This will '
400 'include the common polymer logic needed to boostrap your application.'; 400 'include the common polymer logic needed to boostrap your application.';
401 401
402 const String USE_INIT_DART = 402 const String USE_INIT_DART =
403 'To run a polymer application, you need to call "initPolymer". You can ' 403 'To run a polymer application, you need to call "initPolymer". You can '
404 'either include a generic script tag that does this for you:' 404 'either include a generic script tag that does this for you:'
405 '\'<script type="application/dart">export "package:polymer/init.dart";' 405 '\'<script type="application/dart">export "package:polymer/init.dart";'
406 '</script>\' or add your own script tag and call that function. ' 406 '</script>\' or add your own script tag and call that function. '
407 'Make sure the script tag is placed after all HTML imports.'; 407 'Make sure the script tag is placed after all HTML imports.';
408 408
409 const String NO_DART_SCRIPT_AND_EXPERIMENTAL = 409 const String NO_DART_SCRIPT_AND_EXPERIMENTAL =
410 'The experimental bootstrap feature doesn\'t support script tags on ' 410 'The experimental bootstrap feature doesn\'t support script tags on '
411 'the main document (for now).'; 411 'the main document (for now).';
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer/lib/src/build/script_compactor.dart » ('j') | pkg/polymer/lib/src/build/script_compactor.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698