Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 /// Transfomer that inlines polymer-element definitions from html imports. | 5 /// Transfomer that inlines polymer-element definitions from html imports. |
| 6 library polymer.src.build.import_inliner; | 6 library polymer.src.build.import_inliner; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 | 10 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 return changed; | 330 return changed; |
| 331 } | 331 } |
| 332 | 332 |
| 333 visitElement(Element node) { | 333 visitElement(Element node) { |
| 334 // TODO(jakemac): Support custom elements that extend html elements which | 334 // TODO(jakemac): Support custom elements that extend html elements which |
| 335 // have url-like attributes. This probably means keeping a list of which | 335 // have url-like attributes. This probably means keeping a list of which |
| 336 // html elements support each url-like attribute. | 336 // html elements support each url-like attribute. |
| 337 if (!isCustomTagName(node.localName)) { | 337 if (!isCustomTagName(node.localName)) { |
| 338 node.attributes.forEach((name, value) { | 338 node.attributes.forEach((name, value) { |
| 339 if (_urlAttributes.contains(name)) { | 339 if (_urlAttributes.contains(name)) { |
| 340 if (!name.startsWith('_') && value.contains(_BINDINGS)) { | |
| 341 transform.logger.warning( | |
| 342 'When using bindings with the "$name" attribute you may ' | |
| 343 'experience errors in certain browsers. Please use the ' | |
| 344 '"_$name" attribute instead. For more information, see ' | |
| 345 'http://www.polymer-project.org/docs/polymer/databinding-compat' | |
|
Siggi Cherem (dart-lang)
2014/07/31 21:27:45
Here is the URL shortener that we use in dart2js:
jakemac
2014/08/01 14:24:31
Done.
| |
| 346 '.html#binding-to-attributes', span: node.sourceSpan, | |
| 347 asset: sourceId); | |
| 348 } else if (name.startsWith('_') && !value.contains(_BINDINGS)) { | |
| 349 transform.logger.warning( | |
| 350 'The _$name attribute is only supported when using bindings. ' | |
| 351 'Please change to the $name attribute.'); | |
| 352 } | |
| 340 if (value != '' && !value.trim().startsWith(_BINDINGS)) { | 353 if (value != '' && !value.trim().startsWith(_BINDINGS)) { |
| 341 node.attributes[name] = _newUrl(value, node.sourceSpan); | 354 node.attributes[name] = _newUrl(value, node.sourceSpan); |
| 342 changed = changed || value != node.attributes[name]; | 355 changed = changed || value != node.attributes[name]; |
| 343 } | 356 } |
| 344 } | 357 } |
| 345 }); | 358 }); |
| 346 } | 359 } |
| 347 if (node.localName == 'style') { | 360 if (node.localName == 'style') { |
| 348 node.text = visitCss(node.text); | 361 node.text = visitCss(node.text); |
| 349 changed = true; | 362 changed = true; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 return builder.relative(builder.join('/', id.path), | 463 return builder.relative(builder.join('/', id.path), |
| 451 from: builder.join('/', builder.dirname(primaryId.path))); | 464 from: builder.join('/', builder.dirname(primaryId.path))); |
| 452 } | 465 } |
| 453 } | 466 } |
| 454 | 467 |
| 455 /// HTML attributes that expect a URL value. | 468 /// HTML attributes that expect a URL value. |
| 456 /// <http://dev.w3.org/html5/spec/section-index.html#attributes-1> | 469 /// <http://dev.w3.org/html5/spec/section-index.html#attributes-1> |
| 457 /// | 470 /// |
| 458 /// Every one of these attributes is a URL in every context where it is used in | 471 /// Every one of these attributes is a URL in every context where it is used in |
| 459 /// the DOM. The comments show every DOM element where an attribute can be used. | 472 /// the DOM. The comments show every DOM element where an attribute can be used. |
| 473 /// | |
| 474 /// The _* version of each attribute is also supported, see | |
| 475 /// http://www.polymer-project.org/docs/polymer/databinding-compat.html#binding- to-attributes | |
| 460 const _urlAttributes = const [ | 476 const _urlAttributes = const [ |
| 461 'action', // in form | 477 'action', '_action', // in form |
| 462 'background', // in body | 478 'background', '_background', // in body |
| 463 'cite', // in blockquote, del, ins, q | 479 'cite', '_cite', // in blockquote, del, ins, q |
| 464 'data', // in object | 480 'data', '_data', // in object |
| 465 'formaction', // in button, input | 481 'formaction', '_formaction', // in button, input |
| 466 'href', // in a, area, link, base, command | 482 'href', '_href', // in a, area, link, base, command |
| 467 'icon', // in command | 483 'icon', '_icon', // in command |
| 468 'manifest', // in html | 484 'manifest', '_manifest', // in html |
| 469 'poster', // in video | 485 'poster', '_poster', // in video |
| 470 'src', // in audio, embed, iframe, img, input, script, source, track, | 486 'src', '_src', // in audio, embed, iframe, img, input, script, |
| 471 // video | 487 // source, track,video |
| 472 ]; | 488 ]; |
| 473 | 489 |
| 474 /// When inlining <link rel="stylesheet"> tags copy over all attributes to the | 490 /// When inlining <link rel="stylesheet"> tags copy over all attributes to the |
| 475 /// style tag except these ones. | 491 /// style tag except these ones. |
| 476 const IGNORED_LINKED_STYLE_ATTRS = | 492 const IGNORED_LINKED_STYLE_ATTRS = |
| 477 const ['charset', 'href', 'href-lang', 'rel', 'rev']; | 493 const ['charset', 'href', 'href-lang', 'rel', 'rev']; |
| 478 | 494 |
| 479 /// Global RegExp objects for validating generated library names. | 495 /// Global RegExp objects for validating generated library names. |
| 480 final INVALID_LIB_CHARS_REGEX = new RegExp('[^a-z0-9_]'); | 496 final INVALID_LIB_CHARS_REGEX = new RegExp('[^a-z0-9_]'); |
| 481 final NUM_REGEX = new RegExp('[0-9]'); | 497 final NUM_REGEX = new RegExp('[0-9]'); |
| 482 | 498 |
| 483 _getSpan(SourceFile file, AstNode node) => file.span(node.offset, node.end); | 499 _getSpan(SourceFile file, AstNode node) => file.span(node.offset, node.end); |
| OLD | NEW |