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

Side by Side Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 19663011: Custom Syntax's are now enabled via template.bindingDelegate = (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: restore @Experimental Created 7 years, 5 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 | « pkg/mdv/test/template_element_test.dart ('k') | sdk/lib/html/dartium/html_dartium.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 /// The Dart HTML library. 1 /// The Dart HTML library.
2 /// 2 ///
3 /// For examples, see 3 /// For examples, see
4 /// [Dart HTML5 Samples](https://github.com/dart-lang/dart-html5-samples) 4 /// [Dart HTML5 Samples](https://github.com/dart-lang/dart-html5-samples)
5 /// on Github. 5 /// on Github.
6 library dart.dom.html; 6 library dart.dom.html;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:collection'; 9 import 'dart:collection';
10 import 'dart:_collection-dev' hide Symbol, deprecated; 10 import 'dart:_collection-dev' hide Symbol, deprecated;
(...skipping 8596 matching lines...) Expand 10 before | Expand all | Expand 10 after
8607 * Gets the content of this template. 8607 * Gets the content of this template.
8608 * This is only supported if [isTemplate] is true. 8608 * This is only supported if [isTemplate] is true.
8609 */ 8609 */
8610 @Experimental() 8610 @Experimental()
8611 DocumentFragment get content { 8611 DocumentFragment get content {
8612 _ensureTemplate(); 8612 _ensureTemplate();
8613 return _templateContent; 8613 return _templateContent;
8614 } 8614 }
8615 8615
8616 /** 8616 /**
8617 * Creates an instance of the template. 8617 * Creates an instance of the template, using the provided model and binding
8618 * delegate.
8619 *
8618 * This is only supported if [isTemplate] is true. 8620 * This is only supported if [isTemplate] is true.
8619 */ 8621 */
8620 @Experimental() 8622 @Experimental()
8621 DocumentFragment createInstance(model, String syntax) { 8623 DocumentFragment createInstance(model, BindingDelegate delegate) {
8622 _ensureTemplate(); 8624 _ensureTemplate();
8623 return TemplateElement.mdvPackage(this).createInstance(model, syntax); 8625 return TemplateElement.mdvPackage(this).createInstance(model, delegate);
8624 } 8626 }
8625 8627
8626 /** 8628 /**
8627 * The data model which is inherited through the tree. 8629 * The data model which is inherited through the tree.
8628 * This is only supported if [isTemplate] is true. 8630 * This is only supported if [isTemplate] is true.
8629 */ 8631 */
8630 @Experimental() 8632 @Experimental()
8631 get model => TemplateElement.mdvPackage(this).model; 8633 get model => TemplateElement.mdvPackage(this).model;
8632 8634
8633 @Experimental() 8635 @Experimental()
8634 void set model(value) { 8636 void set model(value) {
8635 _ensureTemplate(); 8637 _ensureTemplate();
8636 TemplateElement.mdvPackage(this).model = value; 8638 TemplateElement.mdvPackage(this).model = value;
8637 } 8639 }
8638 8640
8641 /**
8642 * The binding delegate which is inherited through the tree. It can be used
8643 * to configure custom syntax for `{{bindings}}` inside this template.
8644 *
8645 * This is only supported if [isTemplate] is true.
8646 */
8647 @Experimental()
8648 BindingDelegate get bindingDelegate =>
8649 TemplateElement.mdvPackage(this).bindingDelegate;
8650
8651 @Experimental()
8652 void set bindingDelegate(BindingDelegate value) {
8653 _ensureTemplate();
8654 TemplateElement.mdvPackage(this).bindingDelegate = value;
8655 }
8656
8639 // TODO(jmesserly): const set would be better 8657 // TODO(jmesserly): const set would be better
8640 static const _TABLE_TAGS = const { 8658 static const _TABLE_TAGS = const {
8641 'caption': null, 8659 'caption': null,
8642 'col': null, 8660 'col': null,
8643 'colgroup': null, 8661 'colgroup': null,
8644 'tbody': null, 8662 'tbody': null,
8645 'td': null, 8663 'td': null,
8646 'tfoot': null, 8664 'tfoot': null,
8647 'th': null, 8665 'th': null,
8648 'thead': null, 8666 'thead': null,
(...skipping 12737 matching lines...) Expand 10 before | Expand all | Expand 10 after
21386 @DocsEditable() 21404 @DocsEditable()
21387 Element $dom_insertRow(int index) native; 21405 Element $dom_insertRow(int index) native;
21388 } 21406 }
21389 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 21407 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
21390 // for details. All rights reserved. Use of this source code is governed by a 21408 // for details. All rights reserved. Use of this source code is governed by a
21391 // BSD-style license that can be found in the LICENSE file. 21409 // BSD-style license that can be found in the LICENSE file.
21392 21410
21393 // WARNING: Do not edit - generated code. 21411 // WARNING: Do not edit - generated code.
21394 21412
21395 21413
21396
21397 /** 21414 /**
21398 * Model-Driven Views (MDV)'s native features enables a wide-range of use cases, 21415 * Model-Driven Views (MDV)'s native features enables a wide-range of use cases,
21399 * but (by design) don't attempt to implement a wide array of specialized 21416 * but (by design) don't attempt to implement a wide array of specialized
21400 * behaviors. 21417 * behaviors.
21401 * 21418 *
21402 * Enabling these features in MDV is a matter of implementing and registering an 21419 * Enabling these features in MDV is a matter of implementing and registering an
21403 * MDV Custom Syntax. A Custom Syntax is an object which contains one or more 21420 * MDV Custom Syntax. A Custom Syntax is an object which contains one or more
21404 * delegation functions which implement specialized behavior. This object is 21421 * delegation functions which implement specialized behavior. This object is
21405 * registered with MDV via [TemplateElement.syntax]: 21422 * registered with MDV via [Element.bindingDelegate]:
21406 * 21423 *
21407 * 21424 *
21408 * HTML: 21425 * HTML:
21409 * <template bind syntax="MySyntax"> 21426 * <template bind>
21410 * {{ What!Ever('crazy')->thing^^^I+Want(data) }} 21427 * {{ What!Ever('crazy')->thing^^^I+Want(data) }}
21411 * </template> 21428 * </template>
21412 * 21429 *
21413 * Dart: 21430 * Dart:
21414 * class MySyntax extends CustomBindingSyntax { 21431 * class MySyntax extends BindingDelegate {
21415 * getBinding(model, path, name, node) { 21432 * getBinding(model, path, name, node) {
21416 * // The magic happens here! 21433 * // The magic happens here!
21417 * } 21434 * }
21418 * } 21435 * }
21419 *
21420 * ... 21436 * ...
21421 * 21437 * query('template').bindingDelegate = new MySyntax();
21422 * TemplateElement.syntax['MySyntax'] = new MySyntax(); 21438 * query('template').model = new MyModel();
21423 * 21439 *
21424 * See <https://github.com/polymer-project/mdv/blob/master/docs/syntax.md> for 21440 * See <https://github.com/polymer-project/mdv/blob/master/docs/syntax.md> for
21425 * more information about Custom Syntax. 21441 * more information about Custom Syntax.
21426 */ 21442 */
21427 // TODO(jmesserly): if this is just one method, a function type would make it 21443 // TODO(jmesserly): move this type to the MDV package? Two issues: we'd lose
21428 // more Dart-friendly. 21444 // type annotation on [Element.bindingDelegate], and "mdv" is normally imported
21429 @Experimental() 21445 // with a prefix.
21430 abstract class CustomBindingSyntax { 21446 abstract class BindingDelegate {
21431 /** 21447 /**
21432 * This syntax method allows for a custom interpretation of the contents of 21448 * This syntax method allows for a custom interpretation of the contents of
21433 * mustaches (`{{` ... `}}`). 21449 * mustaches (`{{` ... `}}`).
21434 * 21450 *
21435 * When a template is inserting an instance, it will invoke this method for 21451 * When a template is inserting an instance, it will invoke this method for
21436 * each mustache which is encountered. The function is invoked with four 21452 * each mustache which is encountered. The function is invoked with four
21437 * arguments: 21453 * arguments:
21438 * 21454 *
21439 * - [model]: The data context for which this instance is being created. 21455 * - [model]: The data context for which this instance is being created.
21440 * - [path]: The text contents (trimmed of outer whitespace) of the mustache. 21456 * - [path]: The text contents (trimmed of outer whitespace) of the mustache.
(...skipping 28 matching lines...) Expand all
21469 * instance. 21485 * instance.
21470 * - [model]: The data context for which this instance is being created. 21486 * - [model]: The data context for which this instance is being created.
21471 * 21487 *
21472 * The template element will always use the return value of `getInstanceModel` 21488 * The template element will always use the return value of `getInstanceModel`
21473 * as the model for the new instance. If the syntax does not wish to override 21489 * as the model for the new instance. If the syntax does not wish to override
21474 * the value, it should simply return the `model` value it was passed. 21490 * the value, it should simply return the `model` value it was passed.
21475 */ 21491 */
21476 getInstanceModel(Element template, model) => model; 21492 getInstanceModel(Element template, model) => model;
21477 } 21493 }
21478 21494
21479
21480 @Experimental() 21495 @Experimental()
21481 @DomName('HTMLTemplateElement') 21496 @DomName('HTMLTemplateElement')
21482 @SupportedBrowser(SupportedBrowser.CHROME) 21497 @SupportedBrowser(SupportedBrowser.CHROME)
21483 @Experimental() 21498 @Experimental()
21484 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#t emplate-element 21499 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/templates/index.html#t emplate-element
21485 class TemplateElement extends _HTMLElement native "HTMLTemplateElement" { 21500 class TemplateElement extends _HTMLElement native "HTMLTemplateElement" {
21486 // To suppress missing implicit constructor warnings. 21501 // To suppress missing implicit constructor warnings.
21487 factory TemplateElement._() { throw new UnsupportedError("Not supported"); } 21502 factory TemplateElement._() { throw new UnsupportedError("Not supported"); }
21488 21503
21489 @DomName('HTMLTemplateElement.HTMLTemplateElement') 21504 @DomName('HTMLTemplateElement.HTMLTemplateElement')
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
21689 tr[template], 21704 tr[template],
21690 td[template], 21705 td[template],
21691 caption[template], 21706 caption[template],
21692 colgroup[template], 21707 colgroup[template],
21693 col[template], 21708 col[template],
21694 option[template] { 21709 option[template] {
21695 display: none; 21710 display: none;
21696 }'''; 21711 }''';
21697 document.head.append(style); 21712 document.head.append(style);
21698 } 21713 }
21699
21700 /**
21701 * A mapping of names to Custom Syntax objects. See [CustomBindingSyntax] for
21702 * more information.
21703 */
21704 @Experimental()
21705 static Map<String, CustomBindingSyntax> syntax = {};
21706 } 21714 }
21707 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 21715 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
21708 // for details. All rights reserved. Use of this source code is governed by a 21716 // for details. All rights reserved. Use of this source code is governed by a
21709 // BSD-style license that can be found in the LICENSE file. 21717 // BSD-style license that can be found in the LICENSE file.
21710 21718
21711 // WARNING: Do not edit - generated code. 21719 // WARNING: Do not edit - generated code.
21712 21720
21713 21721
21714 @DomName('Text') 21722 @DomName('Text')
21715 class Text extends CharacterData native "Text" { 21723 class Text extends CharacterData native "Text" {
(...skipping 7750 matching lines...) Expand 10 before | Expand all | Expand 10 after
29466 _position = nextPosition; 29474 _position = nextPosition;
29467 return true; 29475 return true;
29468 } 29476 }
29469 _current = null; 29477 _current = null;
29470 _position = _array.length; 29478 _position = _array.length;
29471 return false; 29479 return false;
29472 } 29480 }
29473 29481
29474 T get current => _current; 29482 T get current => _current;
29475 } 29483 }
OLDNEW
« no previous file with comments | « pkg/mdv/test/template_element_test.dart ('k') | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698