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

Commit

Permalink
fix(Directive): remove publishAs from NgDirective to avoid confusion."
Browse files Browse the repository at this point in the history
This reverts commit c4e6423.

Closes #396
  • Loading branch information
jbdeboer committed Jan 28, 2014
1 parent 8b5971d commit 7ee587f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
35 changes: 19 additions & 16 deletions lib/core/directive.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,10 @@ 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 @@ -208,7 +200,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 @@ -220,14 +212,21 @@ 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,
publishAs,
this.publishAs,
map,
selector,
visibility,
Expand All @@ -238,7 +237,6 @@ class NgComponent extends NgAnnotation {
children: NgAnnotation.COMPILE_CHILDREN,
visibility: visibility,
publishTypes: publishTypes,
publishAs: publishAs,
map: map,
exportExpressions: exportExpressions,
exportExpressionAttrs: exportExpressionAttrs);
Expand Down Expand Up @@ -282,22 +280,20 @@ 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, publishAs: publishAs, map: map,
publishTypes: publishTypes, 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 @@ -327,17 +323,24 @@ 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,
publishAs,
this.publishAs,
map,
selector,
visibility,
publishTypes : const <Type>[],
exportExpressions,
exportExpressionAttrs
}) : super(selector: selector, children: children, visibility: visibility,
publishTypes: publishTypes, publishAs: publishAs, map: map,
publishTypes: publishTypes, map: map,
exportExpressions: exportExpressions,
exportExpressionAttrs: exportExpressionAttrs);

Expand Down
6 changes: 4 additions & 2 deletions lib/core_dom/block_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ 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.publishAs != null) {
(shadowScope == null ? scope : shadowScope)[ref.annotation.publishAs] = controller;
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 (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 {
}


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

0 comments on commit 7ee587f

Please sign in to comment.