From 5926d2e2f7c89dbb2f1222ed08235891d96fa084 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Thu, 12 Mar 2015 13:19:43 +0100 Subject: [PATCH] refactor: use attributes for directives matching Closes #940 --- .../compiler/pipeline/directive_parser.js | 23 ++++-------- .../pipeline/property_binding_parser.js | 13 +++++-- .../core/compiler/pipeline/view_splitter.js | 2 ++ .../test/core/compiler/integration_spec.js | 35 +++++++++++++++++++ .../pipeline/directive_parser_spec.js | 8 +++-- 5 files changed, 60 insertions(+), 21 deletions(-) diff --git a/modules/angular2/src/core/compiler/pipeline/directive_parser.js b/modules/angular2/src/core/compiler/pipeline/directive_parser.js index cf093dee1d..6117eae2e8 100644 --- a/modules/angular2/src/core/compiler/pipeline/directive_parser.js +++ b/modules/angular2/src/core/compiler/pipeline/directive_parser.js @@ -52,27 +52,16 @@ export class DirectiveParser extends CompileStep { for (var i=0; i < classList.length; i++) { cssSelector.addClassName(classList[i]); } + MapWrapper.forEach(attrs, (attrValue, attrName) => { - if (isBlank(current.propertyBindings) || - isPresent(current.propertyBindings) && !MapWrapper.contains(current.propertyBindings, attrName)) { - cssSelector.addAttribute(attrName, attrValue); - } + cssSelector.addAttribute(attrName, attrValue); }); - if (isPresent(current.propertyBindings)) { - MapWrapper.forEach(current.propertyBindings, (expression, prop) => { - cssSelector.addAttribute(prop, expression.source); - }); - } - if (isPresent(current.variableBindings)) { - MapWrapper.forEach(current.variableBindings, (value, name) => { - cssSelector.addAttribute(name, value); - }); - } + // Note: We assume that the ViewSplitter already did its work, i.e. template directive should // only be present on