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

Side by Side Diff: lib/src/info.dart

Issue 13592003: add support for template repeat (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: Created 7 years, 8 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
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 /** 5 /**
6 * Datatypes holding information extracted by the analyzer and used by later 6 * Datatypes holding information extracted by the analyzer and used by later
7 * phases of the compiler. 7 * phases of the compiler.
8 */ 8 */
9 library web_ui.src.info; 9 library web_ui.src.info;
10 10
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 * Collected information about `data-value="name:value"` expressions. 367 * Collected information about `data-value="name:value"` expressions.
368 * Note: this feature is deprecated and should be removed after grace period. 368 * Note: this feature is deprecated and should be removed after grace period.
369 */ 369 */
370 final Map<String, String> values = new SplayTreeMap<String, String>(); 370 final Map<String, String> values = new SplayTreeMap<String, String>();
371 371
372 // TODO(jmesserly): we could keep this local to the analyzer. 372 // TODO(jmesserly): we could keep this local to the analyzer.
373 /** Attribute names to remove in cleanup phase. */ 373 /** Attribute names to remove in cleanup phase. */
374 final Set<String> removeAttributes = new Set<String>(); 374 final Set<String> removeAttributes = new Set<String>();
375 375
376 /** Whether the template element has `iterate="... in ...". */ 376 /** Whether the template element has `iterate="... in ...". */
377 bool get hasIterate => false; 377 bool get hasLoop => false;
378 378
379 /** Whether the template element has an `if="..."` conditional. */ 379 /** Whether the template element has an `if="..."` conditional. */
380 bool get hasIfCondition => false; 380 bool get hasCondition => false;
381 381
382 bool get isTemplateElement => false; 382 bool get isTemplateElement => false;
383 383
384 /** 384 /**
385 * For a builtin HTML element this returns the [node.tagName], otherwise it 385 * For a builtin HTML element this returns the [node.tagName], otherwise it
386 * returns [component.baseExtendsTag]. This is useful when looking up which 386 * returns [component.baseExtendsTag]. This is useful when looking up which
387 * DOM property this element supports. 387 * DOM property this element supports.
388 */ 388 */
389 String get baseTagName => 389 String get baseTagName =>
390 component != null ? component.baseExtendsTag : node.tagName; 390 component != null ? component.baseExtendsTag : node.tagName;
391 391
392 ElementInfo(Element node, ElementInfo parent, [this.component]) 392 ElementInfo(Element node, ElementInfo parent, [this.component])
393 : super(node, parent); 393 : super(node, parent);
394 394
395 String toString() => '#<ElementInfo ' 395 String toString() => '#<ElementInfo '
396 'identifier: $identifier, ' 396 'identifier: $identifier, '
397 'childrenCreatedInCode: $childrenCreatedInCode, ' 397 'childrenCreatedInCode: $childrenCreatedInCode, '
398 'component: $component, ' 398 'component: $component, '
399 'descendantHasBinding: $descendantHasBinding, ' 399 'descendantHasBinding: $descendantHasBinding, '
400 'hasIterate: $hasIterate, ' 400 'hasLoop: $hasLoop, '
401 'hasIfCondition: $hasIfCondition, ' 401 'hasCondition: $hasCondition, '
402 'attributes: $attributes, ' 402 'attributes: $attributes, '
403 'events: $events>'; 403 'events: $events>';
404 } 404 }
405 405
406 /** 406 /**
407 * Information for a single text node created programatically. We create a 407 * Information for a single text node created programatically. We create a
408 * [TextInfo] for data bindings that occur in content nodes, and for each 408 * [TextInfo] for data bindings that occur in content nodes, and for each
409 * text node that is created programatically in code. Note that the analyzer 409 * text node that is created programatically in code. Note that the analyzer
410 * splits HTML text nodes, so that each data-binding has its own node (and 410 * splits HTML text nodes, so that each data-binding has its own node (and
411 * [TextInfo]). 411 * [TextInfo]).
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 */ 539 */
540 final String loopVariable; 540 final String loopVariable;
541 541
542 /** 542 /**
543 * If this is a `<template iterate="item in items">`, this is the expression 543 * If this is a `<template iterate="item in items">`, this is the expression
544 * to get the items to iterate over, e.g. `items`. This will be null if it is 544 * to get the items to iterate over, e.g. `items`. This will be null if it is
545 * not a `<template iterate="...">`. 545 * not a `<template iterate="...">`.
546 */ 546 */
547 final String loopItems; 547 final String loopItems;
548 548
549 /**
550 * True if this is a repeat. Otherwise, it is an iterate.
Siggi Cherem (dart-lang) 2013/04/05 20:09:24 maybe clarify that this is only if 'hasLoop' is tr
Jennifer Messerly 2013/04/05 20:34:36 thanks, clarified.
551 *
552 * For template elements, the two are equivalent, but for template attributes
553 * repeat is more expressive.
554 */
555 final bool isRepeat;
556
549 TemplateInfo(Node node, ElementInfo parent, 557 TemplateInfo(Node node, ElementInfo parent,
550 {this.ifCondition, this.loopVariable, this.loopItems}) 558 {this.ifCondition, this.loopVariable, this.loopItems, this.isRepeat})
551 : super(node, parent) { 559 : super(node, parent) {
552 childrenCreatedInCode = hasIfCondition || hasIterate; 560 childrenCreatedInCode = hasCondition || hasLoop;
553 } 561 }
554 562
555 /** 563 /**
556 * True when [node] is a '<template>' tag. False when [node] is any other 564 * True when [node] is a '<template>' tag. False when [node] is any other
557 * element type and the template information is attached as an attribute. 565 * element type and the template information is attached as an attribute.
558 */ 566 */
559 bool get isTemplateElement => node.tagName == 'template'; 567 bool get isTemplateElement => node.tagName == 'template';
560 568
561 bool get hasIfCondition => ifCondition != null; 569 bool get hasCondition => ifCondition != null;
562 570
563 bool get hasIterate => loopVariable != null; 571 bool get hasLoop => loopVariable != null;
564 572
565 String toString() => '#<TemplateInfo ${super.toString()}' 573 String toString() => '#<TemplateInfo ${super.toString()}'
566 'ifCondition: $ifCondition, ' 574 'ifCondition: $ifCondition, '
567 'loopVariable: $ifCondition, ' 575 'loopVariable: $ifCondition, '
568 'loopItems: $ifCondition>'; 576 'loopItems: $ifCondition>';
569 } 577 }
570 578
571 /** 579 /**
572 * Specifies the action to take on a particular event. Some actions need to read 580 * Specifies the action to take on a particular event. Some actions need to read
573 * attributes from the DOM element that has the event listener (e.g. two way 581 * attributes from the DOM element that has the event listener (e.g. two way
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 */ 619 */
612 class UrlInfo { 620 class UrlInfo {
613 /** Path that the URL points to. */ 621 /** Path that the URL points to. */
614 final String resolvedPath; 622 final String resolvedPath;
615 623
616 /** Original source location where the URL was extracted from. */ 624 /** Original source location where the URL was extracted from. */
617 final Span sourceSpan; 625 final Span sourceSpan;
618 626
619 UrlInfo(this.resolvedPath, this.sourceSpan); 627 UrlInfo(this.resolvedPath, this.sourceSpan);
620 } 628 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698