Skip to content

Commit

Permalink
fix(ngUpgrade): fix downgrade content projection and injector inherit…
Browse files Browse the repository at this point in the history
…ance

- Full support for content projection in downgraded Angular 2
  components. In particular, this enables multi-slot projection and
  other features on <ng-content>.
- Correctly wire up hierarchical injectors for downgraded Angular 2
  components: downgraded components inherit the injector of the first
  other downgraded Angular 2 component they find up the DOM tree.

Closes angular#6629, angular#7727, angular#8729, angular#9643, angular#9649
  • Loading branch information
petebacondarwin committed Nov 3, 2016
1 parent 965bd64 commit 87e7569
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions modules/@angular/upgrade/src/runtime_compiler_spy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import {RuntimeCompilerFactory} from '@angular/compiler';
import {COMPILER_OPTIONS, Compiler, CompilerOptions, Inject, Injectable} from '@angular/core';
import {isPresent} from './facade/lang';

/**
* This class is a map from each component`s selector to that component's `ngContent` selectors.
Expand Down Expand Up @@ -45,7 +44,7 @@ export class RuntimeCompilerSpyFactory extends RuntimeCompilerFactory {
runtimeCompiler._compileTemplate = function(template: any) {
if (!template.isCompiled && !template.isHost) {
const metadata = template.normalizedCompMeta;
if (isPresent(metadata.template) && isPresent(metadata.template.ngContentSelectors)) {
if (metadata.template && metadata.template.ngContentSelectors) {
contentSelectors.set(metadata.selector, metadata.template.ngContentSelectors);
}
}
Expand Down
5 changes: 2 additions & 3 deletions modules/@angular/upgrade/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/
import {CssSelector, SelectorMatcher, createElementCssSelector} from '@angular/compiler';
import {isPresent} from './facade/lang';


export function onError(e: any) {
Expand All @@ -22,7 +21,7 @@ export function controllerKey(name: string): string {
function getAttributesAsArray(node: Node): string[][] {
var attributes = node.attributes;
var asArray: string[][];
if (isPresent(attributes)) {
if (attributes) {
let attrLen = attributes.length;
asArray = new Array(attrLen);
for (var i = 0; i < attrLen; i++) {
Expand Down Expand Up @@ -51,7 +50,7 @@ export function sortProjectableNodes(ngContentSelectors: string[], childNodes: N
matcher.match(
selector, (selector, ngContentIndex) => { ngContentIndices.push(ngContentIndex); });
ngContentIndices.sort();
if (isPresent(wildcardNgContentIndex)) {
if (wildcardNgContentIndex) {
ngContentIndices.push(wildcardNgContentIndex);
}
if (ngContentIndices.length > 0) {
Expand Down

0 comments on commit 87e7569

Please sign in to comment.