fix: flip attr / property bind in directives annotations

Fixes #648

Closes #684
This commit is contained in:
Pawel Kozlowski 2015-02-17 21:55:18 +01:00
parent 709c3ca6b5
commit 56f4e84d45
12 changed files with 36 additions and 36 deletions

View File

@ -68,7 +68,7 @@ Here is a trivial example of a tooltip decorator. The directive will log a toolt
@Decorator({ @Decorator({
selector: '[tooltip]', // CSS Selector which triggers the decorator selector: '[tooltip]', // CSS Selector which triggers the decorator
bind: { // List which properties need to be bound bind: { // List which properties need to be bound
tooltip: 'text' // - DOM element tooltip property should be text: 'tooltip' // - DOM element tooltip property should be
}, // mapped to the directive text property. }, // mapped to the directive text property.
event: { // List which events need to be mapped. event: { // List which events need to be mapped.
mouseover: 'show' // - Invoke the show() method every time mouseover: 'show' // - Invoke the show() method every time
@ -180,7 +180,7 @@ Viewport is a directive which can control instantiation of child views which are
@Viewport({ @Viewport({
selector: '[if]', selector: '[if]',
bind: { bind: {
'if': 'condition' 'condition': 'if'
} }
}) })
export class If { export class If {

View File

@ -196,7 +196,7 @@ export class ElementBinderBuilder extends CompileStep {
var annotation = directive.annotation; var annotation = directive.annotation;
if (isBlank(annotation.bind)) continue; if (isBlank(annotation.bind)) continue;
var _this = this; var _this = this;
StringMapWrapper.forEach(annotation.bind, function (dirProp, elProp) { StringMapWrapper.forEach(annotation.bind, function (elProp, dirProp) {
var expression = isPresent(compileElement.propertyBindings) ? var expression = isPresent(compileElement.propertyBindings) ?
MapWrapper.get(compileElement.propertyBindings, elProp) : MapWrapper.get(compileElement.propertyBindings, elProp) :
null; null;

View File

@ -7,7 +7,7 @@ import {ListWrapper} from 'angular2/src/facade/collection';
@Viewport({ @Viewport({
selector: '[foreach][in]', selector: '[foreach][in]',
bind: { bind: {
'in': 'iterableChanges[]' 'iterableChanges[]': 'in'
} }
}) })
export class Foreach { export class Foreach {

View File

@ -5,7 +5,7 @@ import {isBlank} from 'angular2/src/facade/lang';
@Viewport({ @Viewport({
selector: '[if]', selector: '[if]',
bind: { bind: {
'if': 'condition' 'condition': 'if'
} }
}) })
export class If { export class If {

View File

@ -33,7 +33,7 @@ import {Parent} from 'angular2/src/core/annotations/visibility';
@Decorator({ @Decorator({
selector: '[switch]', selector: '[switch]',
bind: { bind: {
'switch': 'value' 'value': 'switch'
} }
}) })
export class Switch { export class Switch {
@ -144,7 +144,7 @@ export class Switch {
@Viewport({ @Viewport({
selector: '[switch-when]', selector: '[switch-when]',
bind: { bind: {
'switch-when' : 'when' 'when' : 'switch-when'
} }
}) })
export class SwitchWhen { export class SwitchWhen {

View File

@ -99,7 +99,7 @@ export class ControlDirectiveBase {
lifecycle: [onChange], lifecycle: [onChange],
selector: '[control-name]', selector: '[control-name]',
bind: { bind: {
'control-name' : 'controlName', 'controlName' : 'control-name',
'type' : 'type' 'type' : 'type'
} }
}) })
@ -117,7 +117,7 @@ export class ControlNameDirective extends ControlDirectiveBase {
lifecycle: [onChange], lifecycle: [onChange],
selector: '[control]', selector: '[control]',
bind: { bind: {
'control' : 'controlName', 'controlName' : 'control',
'type' : 'type' 'type' : 'type'
} }
}) })
@ -134,7 +134,7 @@ export class ControlDirective extends ControlDirectiveBase {
@Decorator({ @Decorator({
selector: '[control-group]', selector: '[control-group]',
bind: { bind: {
'control-group' : 'controlGroup' 'controlGroup' : 'control-group'
} }
}) })
export class ControlGroupDirective extends ControlGroupDirectiveBase { export class ControlGroupDirective extends ControlGroupDirectiveBase {
@ -163,7 +163,7 @@ export class ControlGroupDirective extends ControlGroupDirectiveBase {
@Component({ @Component({
selector: '[new-control-group]', selector: '[new-control-group]',
bind: { bind: {
'new-control-group' : 'initData' 'initData' : 'new-control-group'
} }
}) })
@Template({inline: '<content>'}) @Template({inline: '<content>'})

View File

@ -288,7 +288,7 @@ export function main() {
@Decorator({ @Decorator({
selector: '[my-dir]', selector: '[my-dir]',
bind: {'elprop':'dirProp'} bind: {'dirProp':'elprop'}
}) })
class MyDir { class MyDir {
dirProp:string; dirProp:string;

View File

@ -448,7 +448,7 @@ class SomeDecoratorDirective {
} }
@Decorator({ @Decorator({
bind: {'boundprop1': 'decorProp'} bind: {'decorProp': 'boundprop1'}
}) })
class SomeDecoratorDirectiveWithBinding { class SomeDecoratorDirectiveWithBinding {
decorProp; decorProp;
@ -461,8 +461,8 @@ class SomeDecoratorDirectiveWithBinding {
@Decorator({ @Decorator({
bind: { bind: {
'boundprop1': 'decorProp', 'decorProp': 'boundprop1',
'boundprop2': 'decorProp2' 'decorProp2': 'boundprop2'
} }
}) })
class SomeDecoratorDirectiveWith2Bindings { class SomeDecoratorDirectiveWith2Bindings {
@ -479,7 +479,7 @@ class SomeViewportDirective {
} }
@Viewport({ @Viewport({
bind: {'boundprop2': 'templProp'} bind: {'templProp': 'boundprop2'}
}) })
class SomeViewportDirectiveWithBinding { class SomeViewportDirectiveWithBinding {
templProp; templProp;
@ -492,7 +492,7 @@ class SomeViewportDirectiveWithBinding {
class SomeComponentDirective { class SomeComponentDirective {
} }
@Component({bind: {'boundprop3': 'compProp'}}) @Component({bind: {'compProp': 'boundprop3'}})
class SomeComponentDirectiveWithBinding { class SomeComponentDirectiveWithBinding {
compProp; compProp;
constructor() { constructor() {

View File

@ -28,31 +28,31 @@ function setupReflector() {
reflector.registerType(Dir0, { reflector.registerType(Dir0, {
"factory": () => new Dir0(), "factory": () => new Dir0(),
"parameters": [], "parameters": [],
"annotations" : [new Decorator({selector: '[dir0]', bind: {'attr0': 'prop'}})] "annotations" : [new Decorator({selector: '[dir0]', bind: {'prop': 'attr0'}})]
}); });
reflector.registerType(Dir1, { reflector.registerType(Dir1, {
"factory": (dir0) => new Dir1(dir0), "factory": (dir0) => new Dir1(dir0),
"parameters": [[Dir0]], "parameters": [[Dir0]],
"annotations" : [new Decorator({selector: '[dir1]', bind: {'attr1': 'prop'}})] "annotations" : [new Decorator({selector: '[dir1]', bind: {'prop': 'attr1'}})]
}); });
reflector.registerType(Dir2, { reflector.registerType(Dir2, {
"factory": (dir1) => new Dir2(dir1), "factory": (dir1) => new Dir2(dir1),
"parameters": [[Dir1]], "parameters": [[Dir1]],
"annotations" : [new Decorator({selector: '[dir2]', bind: {'attr2': 'prop'}})] "annotations" : [new Decorator({selector: '[dir2]', bind: {'prop': 'attr2'}})]
}); });
reflector.registerType(Dir3, { reflector.registerType(Dir3, {
"factory": (dir2) => new Dir3(dir2), "factory": (dir2) => new Dir3(dir2),
"parameters": [[Dir2]], "parameters": [[Dir2]],
"annotations" : [new Decorator({selector: '[dir3]', bind: {'attr3': 'prop'}})] "annotations" : [new Decorator({selector: '[dir3]', bind: {'prop': 'attr3'}})]
}); });
reflector.registerType(Dir4, { reflector.registerType(Dir4, {
"factory": (dir3) => new Dir4(dir3), "factory": (dir3) => new Dir4(dir3),
"parameters": [[Dir3]], "parameters": [[Dir3]],
"annotations" : [new Decorator({selector: '[dir4]', bind: {'attr4': 'prop'}})] "annotations" : [new Decorator({selector: '[dir4]', bind: {'prop': 'attr4'}})]
}); });
reflector.registerGetters({ reflector.registerGetters({
@ -117,7 +117,7 @@ function createTemplateHtml(templateId, repeatCount) {
@Decorator({ @Decorator({
selector: '[dir0]', selector: '[dir0]',
bind: { bind: {
'attr0': 'prop' 'prop': 'attr0'
} }
}) })
class Dir0 {} class Dir0 {}
@ -125,7 +125,7 @@ class Dir0 {}
@Decorator({ @Decorator({
selector: '[dir1]', selector: '[dir1]',
bind: { bind: {
'attr1': 'prop' 'prop': 'attr1'
} }
}) })
class Dir1 { class Dir1 {
@ -135,7 +135,7 @@ class Dir1 {
@Decorator({ @Decorator({
selector: '[dir2]', selector: '[dir2]',
bind: { bind: {
'attr2': 'prop' 'prop': 'attr2'
} }
}) })
class Dir2 { class Dir2 {
@ -145,7 +145,7 @@ class Dir2 {
@Decorator({ @Decorator({
selector: '[dir3]', selector: '[dir3]',
bind: { bind: {
'attr3': 'prop' 'prop': 'attr3'
} }
}) })
class Dir3 { class Dir3 {
@ -155,7 +155,7 @@ class Dir3 {
@Decorator({ @Decorator({
selector: '[dir4]', selector: '[dir4]',
bind: { bind: {
'attr4': 'prop' 'prop': 'attr4'
} }
}) })
class Dir4 { class Dir4 {

View File

@ -104,7 +104,7 @@ export function setupReflectorForCells() {
new Component({ new Component({
selector: 'company-name', selector: 'company-name',
bind: { bind: {
'cell-width': 'width', 'width': 'cell-width',
'company': 'company' 'company': 'company'
} }
}), }),
@ -122,7 +122,7 @@ export function setupReflectorForCells() {
new Component({ new Component({
selector: 'opportunity-name', selector: 'opportunity-name',
bind: { bind: {
'cell-width': 'width', 'width': 'cell-width',
'opportunity': 'opportunity' 'opportunity': 'opportunity'
} }
}), }),
@ -140,7 +140,7 @@ export function setupReflectorForCells() {
new Component({ new Component({
selector: 'offering-name', selector: 'offering-name',
bind: { bind: {
'cell-width': 'width', 'width': 'cell-width',
'offering': 'offering' 'offering': 'offering'
} }
}), }),
@ -158,7 +158,7 @@ export function setupReflectorForCells() {
new Component({ new Component({
selector: 'stage-buttons', selector: 'stage-buttons',
bind: { bind: {
'cell-width': 'width', 'width': 'cell-width',
'offering': 'offering' 'offering': 'offering'
} }
}), }),
@ -184,7 +184,7 @@ export function setupReflectorForCells() {
new Component({ new Component({
selector: 'account-cell', selector: 'account-cell',
bind: { bind: {
'cell-width': 'width', 'width': 'cell-width',
'account': 'account' 'account': 'account'
} }
}), }),
@ -207,7 +207,7 @@ export function setupReflectorForCells() {
new Component({ new Component({
selector: 'formatted-cell', selector: 'formatted-cell',
bind: { bind: {
'cell-width': 'width', 'width': 'cell-width',
'value': 'value' 'value': 'value'
} }
}), }),

View File

@ -158,7 +158,7 @@ export function setupReflectorForAngular() {
'annotations' : [new Viewport({ 'annotations' : [new Viewport({
selector: '[if]', selector: '[if]',
bind: { bind: {
'if': 'condition' 'condition': 'if'
} }
})] })]
}); });
@ -169,7 +169,7 @@ export function setupReflectorForAngular() {
'annotations' : [new Viewport({ 'annotations' : [new Viewport({
selector: '[foreach]', selector: '[foreach]',
bind: { bind: {
'in': 'iterableChanges[]' 'iterableChanges[]': 'in'
} }
})] })]
}); });

View File

@ -54,7 +54,7 @@ function setupReflector() {
'annotations' : [new Viewport({ 'annotations' : [new Viewport({
selector: '[ng-if]', selector: '[ng-if]',
bind: { bind: {
'ng-if': 'ngIf' 'ngIf': 'ng-if'
} }
})] })]
}); });