Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
revert(fix(Directive)): remove publishAs from NgDirective to avoid co…
Browse files Browse the repository at this point in the history
…nfusion.

This reverts commit c48433e.

This commit breaks too much for 0.9.5.  We will reapply it immediately
after the release is cut.
  • Loading branch information
jbdeboer committed Jan 28, 2014
1 parent a7c3a8d commit c4e6423
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 deletions.
35 changes: 16 additions & 19 deletions lib/core/directive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,18 @@ abstract class NgAnnotation {
*/
final List<String> exportExpressions;

/**
* An expression under which the controller instance will be published into.
* This allows the expressions in the template to be referring to controller
* instance and its properties.
*/
final String publishAs;

const NgAnnotation({
this.selector,
this.children: NgAnnotation.COMPILE_CHILDREN,
this.visibility: NgDirective.LOCAL_VISIBILITY,
this.publishAs,
this.publishTypes: const [],
this.map: const {},
this.exportExpressions: const [],
Expand Down Expand Up @@ -200,7 +208,7 @@ class NgComponent extends NgAnnotation {
if (cssUrls != null && cssUrl != null) return [cssUrl]..addAll(cssUrls);
}

/**
/**
* Set the shadow root applyAuthorStyles property. See shadow-DOM
* documentation for further details.
*/
Expand All @@ -212,21 +220,14 @@ class NgComponent extends NgAnnotation {
*/
final bool resetStyleInheritance;

/**
* An expression under which the component's controller instance will be published into.
* This allows the expressions in the template to be referring to controller
* instance and its properties.
*/
final String publishAs;

const NgComponent({
this.template,
this.templateUrl,
this.cssUrl,
this.cssUrls,
this.applyAuthorStyles,
this.resetStyleInheritance,
this.publishAs,
publishAs,
map,
selector,
visibility,
Expand All @@ -237,6 +238,7 @@ class NgComponent extends NgAnnotation {
children: NgAnnotation.COMPILE_CHILDREN,
visibility: visibility,
publishTypes: publishTypes,
publishAs: publishAs,
map: map,
exportExpressions: exportExpressions,
exportExpressionAttrs: exportExpressionAttrs);
Expand Down Expand Up @@ -280,20 +282,22 @@ class NgDirective extends NgAnnotation {

const NgDirective({
children: NgAnnotation.COMPILE_CHILDREN,
publishAs,
map,
selector,
visibility,
publishTypes : const <Type>[],
exportExpressions,
exportExpressionAttrs
}) : super(selector: selector, children: children, visibility: visibility,
publishTypes: publishTypes, map: map,
publishTypes: publishTypes, publishAs: publishAs, map: map,
exportExpressions: exportExpressions,
exportExpressionAttrs: exportExpressionAttrs);

NgAnnotation cloneWithNewMap(newMap) =>
new NgDirective(
children: children,
publishAs: publishAs,
map: newMap,
selector: selector,
visibility: visibility,
Expand Down Expand Up @@ -323,24 +327,17 @@ class NgController extends NgDirective {
static const String CHILDREN_VISIBILITY = 'children';
static const String DIRECT_CHILDREN_VISIBILITY = 'direct_children';

/**
* An expression under which the controller instance will be published into.
* This allows the expressions in the template to be referring to controller
* instance and its properties.
*/
final String publishAs;

const NgController({
children: NgAnnotation.COMPILE_CHILDREN,
this.publishAs,
publishAs,
map,
selector,
visibility,
publishTypes : const <Type>[],
exportExpressions,
exportExpressionAttrs
}) : super(selector: selector, children: children, visibility: visibility,
publishTypes: publishTypes, map: map,
publishTypes: publishTypes, publishAs: publishAs, map: map,
exportExpressions: exportExpressions,
exportExpressionAttrs: exportExpressionAttrs);

Expand Down
6 changes: 2 additions & 4 deletions lib/core_dom/block_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,8 @@ class BlockFactory {
probe.directives.add(controller);
assert((linkMapTimer = _perf.startTimer('ng.block.link.map', ref.type)) != false);
var shadowScope = (fctrs != null && fctrs.containsKey(ref.type)) ? fctrs[ref.type].shadowScope : null;
if (ref.annotation is NgController) {
scope[(ref.annotation as NgController).publishAs] = controller;
} else if (ref.annotation is NgComponent) {
shadowScope[(ref.annotation as NgComponent).publishAs] = controller;
if (ref.annotation.publishAs != null) {
(shadowScope == null ? scope : shadowScope)[ref.annotation.publishAs] = controller;
}
if (nodeAttrs == null) nodeAttrs = new _AnchorAttrs(ref);
for(var map in ref.mappings) {
Expand Down
2 changes: 1 addition & 1 deletion test/core_dom/compiler_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ class PublishMeComponent {
}


@NgController (
@NgDirective (
selector: '[publish-me]',
publishAs: 'ctrlName'
)
Expand Down

0 comments on commit c4e6423

Please sign in to comment.