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

Side by Side Diff: pkg/polymer/lib/src/build/import_inliner.dart

Issue 423713005: add support for _* versions of the url-like attributes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: added tests and shortened link Created 6 years, 4 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
« no previous file with comments | « no previous file | pkg/polymer/test/build/import_inliner_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /// 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
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://goo.gl/5av8cU', span: node.sourceSpan, asset: sourceId);
346 } else if (name.startsWith('_') && !value.contains(_BINDINGS)) {
347 transform.logger.warning(
348 'The "$name" attribute is only supported when using bindings. '
349 'Please change to the "${name.substring(1)}" attribute.',
350 span: node.sourceSpan, asset: sourceId);
351 }
340 if (value != '' && !value.trim().startsWith(_BINDINGS)) { 352 if (value != '' && !value.trim().startsWith(_BINDINGS)) {
341 node.attributes[name] = _newUrl(value, node.sourceSpan); 353 node.attributes[name] = _newUrl(value, node.sourceSpan);
342 changed = changed || value != node.attributes[name]; 354 changed = changed || value != node.attributes[name];
343 } 355 }
344 } 356 }
345 }); 357 });
346 } 358 }
347 if (node.localName == 'style') { 359 if (node.localName == 'style') {
348 node.text = visitCss(node.text); 360 node.text = visitCss(node.text);
349 changed = true; 361 changed = true;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 return builder.relative(builder.join('/', id.path), 462 return builder.relative(builder.join('/', id.path),
451 from: builder.join('/', builder.dirname(primaryId.path))); 463 from: builder.join('/', builder.dirname(primaryId.path)));
452 } 464 }
453 } 465 }
454 466
455 /// HTML attributes that expect a URL value. 467 /// HTML attributes that expect a URL value.
456 /// <http://dev.w3.org/html5/spec/section-index.html#attributes-1> 468 /// <http://dev.w3.org/html5/spec/section-index.html#attributes-1>
457 /// 469 ///
458 /// Every one of these attributes is a URL in every context where it is used in 470 /// 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. 471 /// the DOM. The comments show every DOM element where an attribute can be used.
472 ///
473 /// The _* version of each attribute is also supported, see http://goo.gl/5av8cU
460 const _urlAttributes = const [ 474 const _urlAttributes = const [
461 'action', // in form 475 'action', '_action', // in form
462 'background', // in body 476 'background', '_background', // in body
463 'cite', // in blockquote, del, ins, q 477 'cite', '_cite', // in blockquote, del, ins, q
464 'data', // in object 478 'data', '_data', // in object
465 'formaction', // in button, input 479 'formaction', '_formaction', // in button, input
466 'href', // in a, area, link, base, command 480 'href', '_href', // in a, area, link, base, command
467 'icon', // in command 481 'icon', '_icon', // in command
468 'manifest', // in html 482 'manifest', '_manifest', // in html
469 'poster', // in video 483 'poster', '_poster', // in video
470 'src', // in audio, embed, iframe, img, input, script, source, track, 484 'src', '_src', // in audio, embed, iframe, img, input, script,
471 // video 485 // source, track,video
472 ]; 486 ];
473 487
474 /// When inlining <link rel="stylesheet"> tags copy over all attributes to the 488 /// When inlining <link rel="stylesheet"> tags copy over all attributes to the
475 /// style tag except these ones. 489 /// style tag except these ones.
476 const IGNORED_LINKED_STYLE_ATTRS = 490 const IGNORED_LINKED_STYLE_ATTRS =
477 const ['charset', 'href', 'href-lang', 'rel', 'rev']; 491 const ['charset', 'href', 'href-lang', 'rel', 'rev'];
478 492
479 /// Global RegExp objects for validating generated library names. 493 /// Global RegExp objects for validating generated library names.
480 final INVALID_LIB_CHARS_REGEX = new RegExp('[^a-z0-9_]'); 494 final INVALID_LIB_CHARS_REGEX = new RegExp('[^a-z0-9_]');
481 final NUM_REGEX = new RegExp('[0-9]'); 495 final NUM_REGEX = new RegExp('[0-9]');
482 496
483 _getSpan(SourceFile file, AstNode node) => file.span(node.offset, node.end); 497 _getSpan(SourceFile file, AstNode node) => file.span(node.offset, node.end);
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer/test/build/import_inliner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698