Skip to content

Commit cfb4428

Browse files
Merge pull request #2 from xccvv/master
cx
2 parents 296a455 + 31f27f2 commit cfb4428

13 files changed

Lines changed: 104 additions & 34 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Use imports from `angular2/compiler` instead.
154154
<my-cmp (myEvent)="action()">
155155
<my-cmp [(myProp)]="prop">
156156
<input #myInput>`,
157-
<template ngFor="#myItem" [ngForOf]=items #myIndex="index">
157+
<template ngFor "#myItem" [ngForOf]=items #myIndex="index">
158158
```
159159
160160
The full migration instruction can be found at [angular2/docs/migration/kebab-case.md](https://github.com/angular/angular/blob/master/modules/angular2/docs/migration/kebab-case.md).

COMMITTER.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ Someone with committer access will do the rest.
1111
We have automated the process for merging pull requests into master. Our goal is to minimize the disruption for
1212
Angular committers and also prevent breakages on master.
1313

14-
When a PR is ready to merge, a project member in the CoreTeamMember list (see below) can add the special label,
15-
`PR: merge`.
14+
When a PR has `pr_state: LGTM` and is ready to merge, you should add the `pr_action: merge` label.
15+
Currently (late 2015), we need to ensure that each PR will cleanly merge into the Google-internal version control,
16+
so the caretaker reviews the changes manually.
17+
18+
After this review, the caretaker adds `zomg_admin: do_merge` which is restricted to admins only.
1619
A robot running as [mary-poppins](https://github.com/mary-poppins)
1720
is notified that the label was added by an authorized person,
1821
and will create a new branch in the angular project, using the convention `presubmit-{username}-pr-{number}`.
@@ -26,6 +29,6 @@ Finally, after merge `mary-poppins` removes the presubmit branch.
2629

2730
## Administration
2831

29-
The list of users who can trigger a merge by adding the label is stored in our appengine app datastore.
32+
The list of users who can trigger a merge by adding the `zomg_admin: do_merge` label is stored in our appengine app datastore.
3033
Edit the contents of the [CoreTeamMember Table](
3134
https://console.developers.google.com/project/angular2-automation/datastore/query?queryType=KindQuery&namespace=&kind=CoreTeamMember)

clone.git

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
$ git clone --bare https://github.com/angular/angular.git
2+
# Make a bare clone of the repository
3+
4+
$ cd old-repository.git
5+
$ git push --mirror https://github.com/usernamealreadyis/commands.git
6+
# Mirror-push to the new repository
7+
8+
$ cd ..
9+
$ rm -rf old-repository.git
10+
# Remove our temporary local repository

modules/angular2/docs/cheatsheet/template-syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ Creates a local variable `movieplayer` that provides access to the `video` eleme
6262

6363
@cheatsheetItem
6464
syntax:
65-
`<p *my-unless="myExpression">...</p>`|`*my-unless`
65+
`<p *myUnless="myExpression">...</p>`|`*myUnless`
6666
description:
6767
The `*` symbol means that the current element will be turned into an embedded template. Equivalent to:
68-
`<template [myless]="myExpression"><p>...</p></template>`
68+
`<template [myUnless]="myExpression"><p>...</p></template>`
6969

7070
@cheatsheetItem
7171
syntax:

modules/angular2/src/compiler/template_parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,13 @@ class TemplateParseVisitor implements HtmlAstVisitor {
210210
var attrs = [];
211211

212212
element.attrs.forEach(attr => {
213-
matchableAttrs.push([attr.name, attr.value]);
214213
var hasBinding = this._parseAttr(attr, matchableAttrs, elementOrDirectiveProps, events, vars);
215214
var hasTemplateBinding = this._parseInlineTemplateBinding(
216215
attr, templateMatchableAttrs, templateElementOrDirectiveProps, templateVars);
217216
if (!hasBinding && !hasTemplateBinding) {
218217
// don't include the bindings as attributes as well in the AST
219218
attrs.push(this.visitAttr(attr, null));
219+
matchableAttrs.push([attr.name, attr.value]);
220220
}
221221
if (hasTemplateBinding) {
222222
hasInlineTemplates = true;

modules/angular2/src/facade/lang.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Math {
1111
static final _random = new math.Random();
1212
static int floor(num n) => n.floor();
1313
static double random() => _random.nextDouble();
14+
static num min(num a, num b) => math.min(a, b);
1415
}
1516

1617
class CONST {

modules/angular2/src/router/instruction.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ export abstract class Instruction {
115115

116116
get urlParams(): string[] { return isPresent(this.component) ? this.component.urlParams : []; }
117117

118-
get specificity(): number {
119-
var total = 0;
118+
get specificity(): string {
119+
var total = '';
120120
if (isPresent(this.component)) {
121121
total += this.component.specificity;
122122
}
@@ -305,7 +305,7 @@ export class ComponentInstruction {
305305
public routeData: RouteData;
306306

307307
constructor(public urlPath: string, public urlParams: string[], data: RouteData,
308-
public componentType, public terminal: boolean, public specificity: number,
308+
public componentType, public terminal: boolean, public specificity: string,
309309
public params: {[key: string]: any} = null) {
310310
this.routeData = isPresent(data) ? data : BLANK_ROUTE_DATA;
311311
}

modules/angular2/src/router/path_recognizer.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,45 +96,45 @@ function parsePathString(route: string): {[key: string]: any} {
9696

9797
var segments = splitBySlash(route);
9898
var results = [];
99-
var specificity = 0;
99+
100+
var specificity = '';
101+
102+
// a single slash (or "empty segment" is as specific as a static segment
103+
if (segments.length == 0) {
104+
specificity += '2';
105+
}
100106

101107
// The "specificity" of a path is used to determine which route is used when multiple routes match
102-
// a URL.
103-
// Static segments (like "/foo") are the most specific, followed by dynamic segments (like
104-
// "/:id"). Star segments
105-
// add no specificity. Segments at the start of the path are more specific than proceeding ones.
108+
// a URL. Static segments (like "/foo") are the most specific, followed by dynamic segments (like
109+
// "/:id"). Star segments add no specificity. Segments at the start of the path are more specific
110+
// than proceeding ones.
111+
//
106112
// The code below uses place values to combine the different types of segments into a single
107-
// integer that we can
108-
// sort later. Each static segment is worth hundreds of points of specificity (10000, 9900, ...,
109-
// 200), and each
110-
// dynamic segment is worth single points of specificity (100, 99, ... 2).
111-
if (segments.length > 98) {
112-
throw new BaseException(`'${route}' has more than the maximum supported number of segments.`);
113-
}
113+
// string that we can sort later. Each static segment is marked as a specificity of "2," each
114+
// dynamic segment is worth "1" specificity, and stars are worth "0" specificity.
114115

115116
var limit = segments.length - 1;
116117
for (var i = 0; i <= limit; i++) {
117118
var segment = segments[i], match;
118119

119120
if (isPresent(match = RegExpWrapper.firstMatch(paramMatcher, segment))) {
120121
results.push(new DynamicSegment(match[1]));
121-
specificity += (100 - i);
122+
specificity += '1';
122123
} else if (isPresent(match = RegExpWrapper.firstMatch(wildcardMatcher, segment))) {
123124
results.push(new StarSegment(match[1]));
125+
specificity += '0';
124126
} else if (segment == '...') {
125127
if (i < limit) {
126128
throw new BaseException(`Unexpected "..." before the end of the path for "${route}".`);
127129
}
128130
results.push(new ContinuationSegment());
129131
} else {
130132
results.push(new StaticSegment(segment));
131-
specificity += 100 * (100 - i);
133+
specificity += '2';
132134
}
133135
}
134-
var result = StringMapWrapper.create();
135-
StringMapWrapper.set(result, 'segments', results);
136-
StringMapWrapper.set(result, 'specificity', specificity);
137-
return result;
136+
137+
return {'segments': results, 'specificity': specificity};
138138
}
139139

140140
// this function is used to determine whether a route config path like `/foo/:id` collides with
@@ -177,7 +177,7 @@ function assertPath(path: string) {
177177
*/
178178
export class PathRecognizer {
179179
private _segments: Segment[];
180-
specificity: number;
180+
specificity: string;
181181
terminal: boolean = true;
182182
hash: string;
183183

modules/angular2/src/router/route_recognizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class RedirectRecognizer implements AbstractRecognizer {
5959

6060
// represents something like '/foo/:bar'
6161
export class RouteRecognizer implements AbstractRecognizer {
62-
specificity: number;
62+
specificity: string;
6363
terminal: boolean = true;
6464
hash: string;
6565

modules/angular2/src/router/route_registry.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
isString,
99
isStringMap,
1010
Type,
11+
StringWrapper,
12+
Math,
1113
getTypeNameForDebugging,
1214
CONST_EXPR
1315
} from 'angular2/src/facade/lang';
@@ -492,7 +494,39 @@ function splitAndFlattenLinkParams(linkParams: any[]): any[] {
492494
* Given a list of instructions, returns the most specific instruction
493495
*/
494496
function mostSpecific(instructions: Instruction[]): Instruction {
495-
return ListWrapper.maximum(instructions, (instruction: Instruction) => instruction.specificity);
497+
instructions = instructions.filter((instruction) => isPresent(instruction));
498+
if (instructions.length == 0) {
499+
return null;
500+
}
501+
if (instructions.length == 1) {
502+
return instructions[0];
503+
}
504+
var first = instructions[0];
505+
var rest = instructions.slice(1);
506+
return rest.reduce((instruction: Instruction, contender: Instruction) => {
507+
if (compareSpecificityStrings(contender.specificity, instruction.specificity) == -1) {
508+
return contender;
509+
}
510+
return instruction;
511+
}, first);
512+
}
513+
514+
/*
515+
* Expects strings to be in the form of "[0-2]+"
516+
* Returns -1 if string A should be sorted above string B, 1 if it should be sorted after,
517+
* or 0 if they are the same.
518+
*/
519+
function compareSpecificityStrings(a: string, b: string): number {
520+
var l = Math.min(a.length, b.length);
521+
for (var i = 0; i < l; i += 1) {
522+
var ai = StringWrapper.charCodeAt(a, i);
523+
var bi = StringWrapper.charCodeAt(b, i);
524+
var difference = bi - ai;
525+
if (difference != 0) {
526+
return difference;
527+
}
528+
}
529+
return a.length - b.length;
496530
}
497531

498532
function assertTerminalComponent(component, path) {

0 commit comments

Comments
 (0)