Skip to content

Commit f9e09a0

Browse files
committed
aa966f5 feat(Compiler): Allow overriding the projection selector
1 parent 06af931 commit f9e09a0

69 files changed

Lines changed: 973 additions & 3105 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BUILD_INFO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Thu Mar 24 20:29:10 UTC 2016
2-
c3fa47bbb3156e43b8ee03464cf8e58c4fc73fd6
1+
Thu Mar 24 20:48:37 UTC 2016
2+
aa966f5de2efbaa9b1dc55836b0006315f010576

bundles/angular2-all-testing.umd.dev.js

Lines changed: 29 additions & 59 deletions
Large diffs are not rendered by default.

bundles/angular2-all.umd.dev.js

Lines changed: 29 additions & 59 deletions
Large diffs are not rendered by default.

bundles/angular2-all.umd.js

Lines changed: 28 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,21 +1743,6 @@ return /******/ (function(modules) { // webpackBootstrap
17431743
regExp.lastIndex = 0;
17441744
return { re: regExp, input: input };
17451745
};
1746-
RegExpWrapper.replaceAll = function (regExp, input, replace) {
1747-
var c = regExp.exec(input);
1748-
var res = '';
1749-
regExp.lastIndex = 0;
1750-
var prev = 0;
1751-
while (c) {
1752-
res += input.substring(prev, c.index);
1753-
res += replace(c);
1754-
prev = c.index + c[0].length;
1755-
regExp.lastIndex = prev;
1756-
c = regExp.exec(input);
1757-
}
1758-
res += input.substring(prev);
1759-
return res;
1760-
};
17611746
return RegExpWrapper;
17621747
})();
17631748
exports.RegExpWrapper = RegExpWrapper;
@@ -3833,11 +3818,6 @@ return /******/ (function(modules) { // webpackBootstrap
38333818
return solution;
38343819
};
38353820
ListWrapper.isImmutable = function (list) { return Object.isSealed(list); };
3836-
ListWrapper.flatten = function (array) {
3837-
var res = [];
3838-
array.forEach(function (a) { return res = res.concat(a); });
3839-
return res;
3840-
};
38413821
return ListWrapper;
38423822
})();
38433823
exports.ListWrapper = ListWrapper;
@@ -8628,14 +8608,6 @@ return /******/ (function(modules) { // webpackBootstrap
86288608
}
86298609
return ParseException;
86308610
})(exceptions_1.BaseException);
8631-
var SplitInterpolation = (function () {
8632-
function SplitInterpolation(strings, expressions) {
8633-
this.strings = strings;
8634-
this.expressions = expressions;
8635-
}
8636-
return SplitInterpolation;
8637-
})();
8638-
exports.SplitInterpolation = SplitInterpolation;
86398611
var Parser = (function () {
86408612
function Parser(/** @internal */ _lexer, providedReflector) {
86418613
if (providedReflector === void 0) { providedReflector = null; }
@@ -8687,18 +8659,6 @@ return /******/ (function(modules) { // webpackBootstrap
86878659
return new _ParseAST(input, location, tokens, this._reflector, false).parseTemplateBindings();
86888660
};
86898661
Parser.prototype.parseInterpolation = function (input, location) {
8690-
var split = this.splitInterpolation(input, location);
8691-
if (split == null)
8692-
return null;
8693-
var expressions = [];
8694-
for (var i = 0; i < split.expressions.length; ++i) {
8695-
var tokens = this._lexer.tokenize(split.expressions[i]);
8696-
var ast = new _ParseAST(input, location, tokens, this._reflector, false).parseChain();
8697-
expressions.push(ast);
8698-
}
8699-
return new ast_1.ASTWithSource(new ast_1.Interpolation(split.strings, expressions), input, location);
8700-
};
8701-
Parser.prototype.splitInterpolation = function (input, location) {
87028662
var parts = lang_1.StringWrapper.split(input, INTERPOLATION_REGEXP);
87038663
if (parts.length <= 1) {
87048664
return null;
@@ -8712,13 +8672,15 @@ return /******/ (function(modules) { // webpackBootstrap
87128672
strings.push(part);
87138673
}
87148674
else if (part.trim().length > 0) {
8715-
expressions.push(part);
8675+
var tokens = this._lexer.tokenize(part);
8676+
var ast = new _ParseAST(input, location, tokens, this._reflector, false).parseChain();
8677+
expressions.push(ast);
87168678
}
87178679
else {
87188680
throw new ParseException('Blank expressions are not allowed in interpolated strings', input, "at column " + this._findInterpolationErrorColumn(parts, i) + " in", location);
87198681
}
87208682
}
8721-
return new SplitInterpolation(strings, expressions);
8683+
return new ast_1.ASTWithSource(new ast_1.Interpolation(strings, expressions), input, location);
87228684
};
87238685
Parser.prototype.wrapLiteralPrimitive = function (input, location) {
87248686
return new ast_1.ASTWithSource(new ast_1.LiteralPrimitive(input), input, location);
@@ -26405,32 +26367,37 @@ return /******/ (function(modules) { // webpackBootstrap
2640526367
var directives = this._createDirectiveAsts(element.name, this._parseDirectives(this.selectorMatcher, elementCssSelector), elementOrDirectiveProps, isTemplateElement ? [] : vars, element.sourceSpan);
2640626368
var elementProps = this._createElementPropertyAsts(element.name, elementOrDirectiveProps, directives);
2640726369
var children = html_ast_1.htmlVisitAll(preparsedElement.nonBindable ? NON_BINDABLE_VISITOR : this, element.children, Component.create(directives));
26408-
var elementNgContentIndex = hasInlineTemplates ? null : component.findNgContentIndex(elementCssSelector);
26370+
// Override the actual selector when the `ngProjectAs` attribute is provided
26371+
var projectionSelector = lang_1.isPresent(preparsedElement.projectAs) ?
26372+
selector_1.CssSelector.parse(preparsedElement.projectAs)[0] :
26373+
elementCssSelector;
26374+
var ngContentIndex = component.findNgContentIndex(projectionSelector);
2640926375
var parsedElement;
2641026376
if (preparsedElement.type === template_preparser_1.PreparsedElementType.NG_CONTENT) {
2641126377
if (lang_1.isPresent(element.children) && element.children.length > 0) {
2641226378
this._reportError("<ng-content> element cannot have content. <ng-content> must be immediately followed by </ng-content>", element.sourceSpan);
2641326379
}
26414-
parsedElement =
26415-
new template_ast_1.NgContentAst(this.ngContentCount++, elementNgContentIndex, element.sourceSpan);
26380+
parsedElement = new template_ast_1.NgContentAst(this.ngContentCount++, hasInlineTemplates ? null : ngContentIndex, element.sourceSpan);
2641626381
}
2641726382
else if (isTemplateElement) {
2641826383
this._assertAllEventsPublishedByDirectives(directives, events);
2641926384
this._assertNoComponentsNorElementBindingsOnTemplate(directives, elementProps, element.sourceSpan);
26420-
parsedElement = new template_ast_1.EmbeddedTemplateAst(attrs, events, vars, directives, children, elementNgContentIndex, element.sourceSpan);
26385+
parsedElement =
26386+
new template_ast_1.EmbeddedTemplateAst(attrs, events, vars, directives, children, hasInlineTemplates ? null : ngContentIndex, element.sourceSpan);
2642126387
}
2642226388
else {
2642326389
this._assertOnlyOneComponent(directives, element.sourceSpan);
2642426390
var elementExportAsVars = vars.filter(function (varAst) { return varAst.value.length === 0; });
26391+
var ngContentIndex_1 = hasInlineTemplates ? null : component.findNgContentIndex(projectionSelector);
2642526392
parsedElement =
26426-
new template_ast_1.ElementAst(nodeName, attrs, elementProps, events, elementExportAsVars, directives, children, elementNgContentIndex, element.sourceSpan);
26393+
new template_ast_1.ElementAst(nodeName, attrs, elementProps, events, elementExportAsVars, directives, children, hasInlineTemplates ? null : ngContentIndex_1, element.sourceSpan);
2642726394
}
2642826395
if (hasInlineTemplates) {
2642926396
var templateCssSelector = createElementCssSelector(TEMPLATE_ELEMENT, templateMatchableAttrs);
2643026397
var templateDirectives = this._createDirectiveAsts(element.name, this._parseDirectives(this.selectorMatcher, templateCssSelector), templateElementOrDirectiveProps, [], element.sourceSpan);
2643126398
var templateElementProps = this._createElementPropertyAsts(element.name, templateElementOrDirectiveProps, templateDirectives);
2643226399
this._assertNoComponentsNorElementBindingsOnTemplate(templateDirectives, templateElementProps, element.sourceSpan);
26433-
parsedElement = new template_ast_1.EmbeddedTemplateAst([], [], templateVars, templateDirectives, [parsedElement], component.findNgContentIndex(templateCssSelector), element.sourceSpan);
26400+
parsedElement = new template_ast_1.EmbeddedTemplateAst([], [], templateVars, templateDirectives, [parsedElement], ngContentIndex, element.sourceSpan);
2643426401
}
2643526402
return parsedElement;
2643626403
};
@@ -27003,12 +26970,10 @@ return /******/ (function(modules) { // webpackBootstrap
2700326970
selfClosing = false;
2700426971
}
2700526972
var end = this.peek.sourceSpan.start;
27006-
var span = new parse_util_1.ParseSourceSpan(startTagToken.sourceSpan.start, end);
27007-
var el = new html_ast_1.HtmlElementAst(fullName, attrs, [], span, span, null);
26973+
var el = new html_ast_1.HtmlElementAst(fullName, attrs, [], new parse_util_1.ParseSourceSpan(startTagToken.sourceSpan.start, end));
2700826974
this._pushElement(el);
2700926975
if (selfClosing) {
2701026976
this._popElement(fullName);
27011-
el.endSourceSpan = span;
2701226977
}
2701326978
};
2701426979
TreeBuilder.prototype._pushElement = function (el) {
@@ -27021,7 +26986,7 @@ return /******/ (function(modules) { // webpackBootstrap
2702126986
var tagDef = html_tags_1.getHtmlTagDefinition(el.name);
2702226987
var parentEl = this._getParentElement();
2702326988
if (tagDef.requireExtraParent(lang_1.isPresent(parentEl) ? parentEl.name : null)) {
27024-
var newParent = new html_ast_1.HtmlElementAst(tagDef.parentToAdd, [], [el], el.sourceSpan, el.startSourceSpan, el.endSourceSpan);
26989+
var newParent = new html_ast_1.HtmlElementAst(tagDef.parentToAdd, [], [el], el.sourceSpan);
2702526990
this._addToParent(newParent);
2702626991
this.elementStack.push(newParent);
2702726992
this.elementStack.push(el);
@@ -27033,7 +26998,6 @@ return /******/ (function(modules) { // webpackBootstrap
2703326998
};
2703426999
TreeBuilder.prototype._consumeEndTag = function (endTagToken) {
2703527000
var fullName = getElementFullName(endTagToken.parts[0], endTagToken.parts[1], this._getParentElement());
27036-
this._getParentElement().endSourceSpan = endTagToken.sourceSpan;
2703727001
if (html_tags_1.getHtmlTagDefinition(fullName).isVoid) {
2703827002
this.errors.push(HtmlTreeError.create(fullName, endTagToken.sourceSpan, "Void elements do not have end tags \"" + endTagToken.parts[1] + "\""));
2703927003
}
@@ -27115,13 +27079,11 @@ return /******/ (function(modules) { // webpackBootstrap
2711527079
})();
2711627080
exports.HtmlAttrAst = HtmlAttrAst;
2711727081
var HtmlElementAst = (function () {
27118-
function HtmlElementAst(name, attrs, children, sourceSpan, startSourceSpan, endSourceSpan) {
27082+
function HtmlElementAst(name, attrs, children, sourceSpan) {
2711927083
this.name = name;
2712027084
this.attrs = attrs;
2712127085
this.children = children;
2712227086
this.sourceSpan = sourceSpan;
27123-
this.startSourceSpan = startSourceSpan;
27124-
this.endSourceSpan = endSourceSpan;
2712527087
}
2712627088
HtmlElementAst.prototype.visit = function (visitor, context) { return visitor.visitElement(this, context); };
2712727089
return HtmlElementAst;
@@ -28232,11 +28194,13 @@ return /******/ (function(modules) { // webpackBootstrap
2823228194
var STYLE_ELEMENT = 'style';
2823328195
var SCRIPT_ELEMENT = 'script';
2823428196
var NG_NON_BINDABLE_ATTR = 'ngNonBindable';
28197+
var NG_PROJECT_AS = 'ngProjectAs';
2823528198
function preparseElement(ast) {
2823628199
var selectAttr = null;
2823728200
var hrefAttr = null;
2823828201
var relAttr = null;
2823928202
var nonBindable = false;
28203+
var projectAs = null;
2824028204
ast.attrs.forEach(function (attr) {
2824128205
var lcAttrName = attr.name.toLowerCase();
2824228206
if (lcAttrName == NG_CONTENT_SELECT_ATTR) {
@@ -28251,6 +28215,11 @@ return /******/ (function(modules) { // webpackBootstrap
2825128215
else if (attr.name == NG_NON_BINDABLE_ATTR) {
2825228216
nonBindable = true;
2825328217
}
28218+
else if (attr.name == NG_PROJECT_AS) {
28219+
if (attr.value.length > 0) {
28220+
projectAs = attr.value;
28221+
}
28222+
}
2825428223
});
2825528224
selectAttr = normalizeNgContentSelect(selectAttr);
2825628225
var nodeName = ast.name.toLowerCase();
@@ -28267,7 +28236,7 @@ return /******/ (function(modules) { // webpackBootstrap
2826728236
else if (nodeName == LINK_ELEMENT && relAttr == LINK_STYLE_REL_VALUE) {
2826828237
type = PreparsedElementType.STYLESHEET;
2826928238
}
28270-
return new PreparsedElement(type, selectAttr, hrefAttr, nonBindable);
28239+
return new PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs);
2827128240
}
2827228241
exports.preparseElement = preparseElement;
2827328242
(function (PreparsedElementType) {
@@ -28279,11 +28248,12 @@ return /******/ (function(modules) { // webpackBootstrap
2827928248
})(exports.PreparsedElementType || (exports.PreparsedElementType = {}));
2828028249
var PreparsedElementType = exports.PreparsedElementType;
2828128250
var PreparsedElement = (function () {
28282-
function PreparsedElement(type, selectAttr, hrefAttr, nonBindable) {
28251+
function PreparsedElement(type, selectAttr, hrefAttr, nonBindable, projectAs) {
2828328252
this.type = type;
2828428253
this.selectAttr = selectAttr;
2828528254
this.hrefAttr = hrefAttr;
2828628255
this.nonBindable = nonBindable;
28256+
this.projectAs = projectAs;
2828728257
}
2828828258
return PreparsedElement;
2828928259
})();

bundles/angular2-all.umd.min.js

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)