revert(format): Revert "chore(format): update to latest formatter"
This reverts commit 03627aa84d
.
This commit is contained in:
@ -1,12 +1,27 @@
|
||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/testing_internal';
|
||||
import {
|
||||
ddescribe,
|
||||
describe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {isPresent} from 'angular2/src/facade/lang';
|
||||
import {isPresent} from "angular2/src/facade/lang";
|
||||
|
||||
import {CssToken, CssScannerError, CssLexer, CssLexerMode, CssTokenType} from 'angular2/src/compiler/css/lexer';
|
||||
import {
|
||||
CssToken,
|
||||
CssScannerError,
|
||||
CssLexer,
|
||||
CssLexerMode,
|
||||
CssTokenType
|
||||
} from 'angular2/src/compiler/css/lexer';
|
||||
|
||||
export function main() {
|
||||
function tokenize(
|
||||
code, trackComments: boolean = false, mode: CssLexerMode = CssLexerMode.ALL): CssToken[] {
|
||||
function tokenize(code, trackComments: boolean = false,
|
||||
mode: CssLexerMode = CssLexerMode.ALL): CssToken[] {
|
||||
var scanner = new CssLexer().scan(code, trackComments);
|
||||
scanner.setMode(mode);
|
||||
|
||||
@ -26,7 +41,7 @@ export function main() {
|
||||
|
||||
describe('CssLexer', () => {
|
||||
it('should lex newline characters as whitespace when whitespace mode is on', () => {
|
||||
var newlines = ['\n', '\r\n', '\r', '\f'];
|
||||
var newlines = ["\n", "\r\n", "\r", "\f"];
|
||||
newlines.forEach((line) => {
|
||||
var token = tokenize(line, false, CssLexerMode.ALL_TRACK_WS)[0];
|
||||
expect(token.type).toEqual(CssTokenType.Whitespace);
|
||||
@ -34,7 +49,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should combined newline characters as one newline token when whitespace mode is on', () => {
|
||||
var newlines = ['\n', '\r\n', '\r', '\f'].join('');
|
||||
var newlines = ["\n", "\r\n", "\r", "\f"].join("");
|
||||
var tokens = tokenize(newlines, false, CssLexerMode.ALL_TRACK_WS);
|
||||
expect(tokens.length).toEqual(1);
|
||||
expect(tokens[0].type).toEqual(CssTokenType.Whitespace);
|
||||
@ -42,14 +57,13 @@ export function main() {
|
||||
|
||||
it('should not consider whitespace or newline values at all when whitespace mode is off',
|
||||
() => {
|
||||
var newlines = ['\n', '\r\n', '\r', '\f'].join('');
|
||||
var newlines = ["\n", "\r\n", "\r", "\f"].join("");
|
||||
var tokens = tokenize(newlines);
|
||||
expect(tokens.length).toEqual(0);
|
||||
});
|
||||
|
||||
it('should lex simple selectors and their inner properties', () => {
|
||||
var cssCode = '\n' +
|
||||
' .selector { my-prop: my-value; }\n';
|
||||
var cssCode = "\n" + " .selector { my-prop: my-value; }\n";
|
||||
var tokens = tokenize(cssCode);
|
||||
|
||||
expect(tokens[0].type).toEqual(CssTokenType.Character);
|
||||
@ -78,9 +92,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should capture the column and line values for each token', () => {
|
||||
var cssCode = '#id {\n' +
|
||||
' prop:value;\n' +
|
||||
'}';
|
||||
var cssCode = "#id {\n" + " prop:value;\n" + "}";
|
||||
|
||||
var tokens = tokenize(cssCode);
|
||||
|
||||
@ -126,13 +138,13 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should lex quoted strings and escape accordingly', () => {
|
||||
var cssCode = 'prop: \'some { value } \\\' that is quoted\'';
|
||||
var cssCode = "prop: 'some { value } \\' that is quoted'";
|
||||
var tokens = tokenize(cssCode);
|
||||
|
||||
expect(tokens[0].type).toEqual(CssTokenType.Identifier);
|
||||
expect(tokens[1].type).toEqual(CssTokenType.Character);
|
||||
expect(tokens[2].type).toEqual(CssTokenType.String);
|
||||
expect(tokens[2].strValue).toEqual('\'some { value } \\\' that is quoted\'');
|
||||
expect(tokens[2].strValue).toEqual("'some { value } \\' that is quoted'");
|
||||
});
|
||||
|
||||
it('should treat attribute operators as regular characters', () => {
|
||||
@ -140,27 +152,27 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should lex numbers properly and set them as numbers', () => {
|
||||
var cssCode = '0 1 -2 3.0 -4.001';
|
||||
var cssCode = "0 1 -2 3.0 -4.001";
|
||||
var tokens = tokenize(cssCode);
|
||||
|
||||
expect(tokens[0].type).toEqual(CssTokenType.Number);
|
||||
expect(tokens[0].strValue).toEqual('0');
|
||||
expect(tokens[0].strValue).toEqual("0");
|
||||
|
||||
expect(tokens[1].type).toEqual(CssTokenType.Number);
|
||||
expect(tokens[1].strValue).toEqual('1');
|
||||
expect(tokens[1].strValue).toEqual("1");
|
||||
|
||||
expect(tokens[2].type).toEqual(CssTokenType.Number);
|
||||
expect(tokens[2].strValue).toEqual('-2');
|
||||
expect(tokens[2].strValue).toEqual("-2");
|
||||
|
||||
expect(tokens[3].type).toEqual(CssTokenType.Number);
|
||||
expect(tokens[3].strValue).toEqual('3.0');
|
||||
expect(tokens[3].strValue).toEqual("3.0");
|
||||
|
||||
expect(tokens[4].type).toEqual(CssTokenType.Number);
|
||||
expect(tokens[4].strValue).toEqual('-4.001');
|
||||
expect(tokens[4].strValue).toEqual("-4.001");
|
||||
});
|
||||
|
||||
it('should lex @keywords', () => {
|
||||
var cssCode = '@import()@something';
|
||||
var cssCode = "@import()@something";
|
||||
var tokens = tokenize(cssCode);
|
||||
|
||||
expect(tokens[0].type).toEqual(CssTokenType.AtKeyword);
|
||||
@ -177,7 +189,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should still lex a number even if it has a dimension suffix', () => {
|
||||
var cssCode = '40% is 40 percent';
|
||||
var cssCode = "40% is 40 percent";
|
||||
var tokens = tokenize(cssCode);
|
||||
|
||||
expect(tokens[0].type).toEqual(CssTokenType.Number);
|
||||
@ -194,7 +206,7 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should allow escaped character and unicode character-strings in CSS selectors', () => {
|
||||
var cssCode = '\\123456 .some\\thing \{\}';
|
||||
var cssCode = "\\123456 .some\\thing \{\}";
|
||||
var tokens = tokenize(cssCode);
|
||||
|
||||
expect(tokens[0].type).toEqual(CssTokenType.Identifier);
|
||||
@ -206,67 +218,67 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should distinguish identifiers and numbers from special characters', () => {
|
||||
var cssCode = 'one*two=-4+three-4-equals_value$';
|
||||
var cssCode = "one*two=-4+three-4-equals_value$";
|
||||
var tokens = tokenize(cssCode);
|
||||
|
||||
expect(tokens[0].type).toEqual(CssTokenType.Identifier);
|
||||
expect(tokens[0].strValue).toEqual('one');
|
||||
expect(tokens[0].strValue).toEqual("one");
|
||||
|
||||
expect(tokens[1].type).toEqual(CssTokenType.Character);
|
||||
expect(tokens[1].strValue).toEqual('*');
|
||||
expect(tokens[1].strValue).toEqual("*");
|
||||
|
||||
expect(tokens[2].type).toEqual(CssTokenType.Identifier);
|
||||
expect(tokens[2].strValue).toEqual('two');
|
||||
expect(tokens[2].strValue).toEqual("two");
|
||||
|
||||
expect(tokens[3].type).toEqual(CssTokenType.Character);
|
||||
expect(tokens[3].strValue).toEqual('=');
|
||||
expect(tokens[3].strValue).toEqual("=");
|
||||
|
||||
expect(tokens[4].type).toEqual(CssTokenType.Number);
|
||||
expect(tokens[4].strValue).toEqual('-4');
|
||||
expect(tokens[4].strValue).toEqual("-4");
|
||||
|
||||
expect(tokens[5].type).toEqual(CssTokenType.Character);
|
||||
expect(tokens[5].strValue).toEqual('+');
|
||||
expect(tokens[5].strValue).toEqual("+");
|
||||
|
||||
expect(tokens[6].type).toEqual(CssTokenType.Identifier);
|
||||
expect(tokens[6].strValue).toEqual('three-4-equals_value');
|
||||
expect(tokens[6].strValue).toEqual("three-4-equals_value");
|
||||
|
||||
expect(tokens[7].type).toEqual(CssTokenType.Character);
|
||||
expect(tokens[7].strValue).toEqual('$');
|
||||
expect(tokens[7].strValue).toEqual("$");
|
||||
});
|
||||
|
||||
it('should filter out comments and whitespace by default', () => {
|
||||
var cssCode = '.selector /* comment */ { /* value */ }';
|
||||
var cssCode = ".selector /* comment */ { /* value */ }";
|
||||
var tokens = tokenize(cssCode);
|
||||
|
||||
expect(tokens[0].strValue).toEqual('.');
|
||||
expect(tokens[1].strValue).toEqual('selector');
|
||||
expect(tokens[2].strValue).toEqual('{');
|
||||
expect(tokens[3].strValue).toEqual('}');
|
||||
expect(tokens[0].strValue).toEqual(".");
|
||||
expect(tokens[1].strValue).toEqual("selector");
|
||||
expect(tokens[2].strValue).toEqual("{");
|
||||
expect(tokens[3].strValue).toEqual("}");
|
||||
});
|
||||
|
||||
it('should track comments when the flag is set to true', () => {
|
||||
var cssCode = '.selector /* comment */ { /* value */ }';
|
||||
var cssCode = ".selector /* comment */ { /* value */ }";
|
||||
var trackComments = true;
|
||||
var tokens = tokenize(cssCode, trackComments, CssLexerMode.ALL_TRACK_WS);
|
||||
|
||||
expect(tokens[0].strValue).toEqual('.');
|
||||
expect(tokens[1].strValue).toEqual('selector');
|
||||
expect(tokens[2].strValue).toEqual(' ');
|
||||
expect(tokens[0].strValue).toEqual(".");
|
||||
expect(tokens[1].strValue).toEqual("selector");
|
||||
expect(tokens[2].strValue).toEqual(" ");
|
||||
|
||||
expect(tokens[3].type).toEqual(CssTokenType.Comment);
|
||||
expect(tokens[3].strValue).toEqual('/* comment */');
|
||||
expect(tokens[3].strValue).toEqual("/* comment */");
|
||||
|
||||
expect(tokens[4].strValue).toEqual(' ');
|
||||
expect(tokens[5].strValue).toEqual('{');
|
||||
expect(tokens[6].strValue).toEqual(' ');
|
||||
expect(tokens[4].strValue).toEqual(" ");
|
||||
expect(tokens[5].strValue).toEqual("{");
|
||||
expect(tokens[6].strValue).toEqual(" ");
|
||||
|
||||
expect(tokens[7].type).toEqual(CssTokenType.Comment);
|
||||
expect(tokens[7].strValue).toEqual('/* value */');
|
||||
expect(tokens[7].strValue).toEqual("/* value */");
|
||||
});
|
||||
|
||||
describe('Selector Mode', () => {
|
||||
it('should throw an error if a selector is being parsed while in the wrong mode', () => {
|
||||
var cssCode = '.class > tag';
|
||||
var cssCode = ".class > tag";
|
||||
|
||||
var capturedMessage;
|
||||
try {
|
||||
@ -293,18 +305,18 @@ export function main() {
|
||||
it('should consider attribute selectors as valid input and throw when an invalid modifier is used',
|
||||
() => {
|
||||
function tokenizeAttr(modifier) {
|
||||
var cssCode = 'value' + modifier + '=\'something\'';
|
||||
var cssCode = "value" + modifier + "='something'";
|
||||
return tokenize(cssCode, false, CssLexerMode.ATTRIBUTE_SELECTOR);
|
||||
}
|
||||
|
||||
expect(tokenizeAttr('*').length).toEqual(4);
|
||||
expect(tokenizeAttr('|').length).toEqual(4);
|
||||
expect(tokenizeAttr('^').length).toEqual(4);
|
||||
expect(tokenizeAttr('$').length).toEqual(4);
|
||||
expect(tokenizeAttr('~').length).toEqual(4);
|
||||
expect(tokenizeAttr('').length).toEqual(3);
|
||||
expect(tokenizeAttr("*").length).toEqual(4);
|
||||
expect(tokenizeAttr("|").length).toEqual(4);
|
||||
expect(tokenizeAttr("^").length).toEqual(4);
|
||||
expect(tokenizeAttr("$").length).toEqual(4);
|
||||
expect(tokenizeAttr("~").length).toEqual(4);
|
||||
expect(tokenizeAttr("").length).toEqual(3);
|
||||
|
||||
expect(() => { tokenizeAttr('+'); }).toThrow();
|
||||
expect(() => { tokenizeAttr("+"); }).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@ -314,15 +326,15 @@ export function main() {
|
||||
|
||||
// the reason why the numbers are so high is because MediaQueries keep
|
||||
// track of the whitespace values
|
||||
expect(tokenizeQuery('(prop: value)').length).toEqual(5);
|
||||
expect(tokenizeQuery('(prop: value) and (prop2: value2)').length).toEqual(11);
|
||||
expect(tokenizeQuery('tv and (prop: value)').length).toEqual(7);
|
||||
expect(tokenizeQuery('print and ((prop: value) or (prop2: value2))').length).toEqual(15);
|
||||
expect(tokenizeQuery('(content: \'something $ crazy inside &\')').length).toEqual(5);
|
||||
expect(tokenizeQuery("(prop: value)").length).toEqual(5);
|
||||
expect(tokenizeQuery("(prop: value) and (prop2: value2)").length).toEqual(11);
|
||||
expect(tokenizeQuery("tv and (prop: value)").length).toEqual(7);
|
||||
expect(tokenizeQuery("print and ((prop: value) or (prop2: value2))").length).toEqual(15);
|
||||
expect(tokenizeQuery("(content: 'something $ crazy inside &')").length).toEqual(5);
|
||||
|
||||
expect(() => { tokenizeQuery('(max-height: 10 + 20)'); }).toThrow();
|
||||
expect(() => { tokenizeQuery("(max-height: 10 + 20)"); }).toThrow();
|
||||
|
||||
expect(() => { tokenizeQuery('(max-height: fifty < 100)'); }).toThrow();
|
||||
expect(() => { tokenizeQuery("(max-height: fifty < 100)"); }).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@ -333,13 +345,13 @@ export function main() {
|
||||
return tokenize(code, false, CssLexerMode.PSEUDO_SELECTOR);
|
||||
}
|
||||
|
||||
expect(tokenizePseudo('lang(en-us)').length).toEqual(4);
|
||||
expect(tokenizePseudo('hover').length).toEqual(1);
|
||||
expect(tokenizePseudo('focus').length).toEqual(1);
|
||||
expect(tokenizePseudo("lang(en-us)").length).toEqual(4);
|
||||
expect(tokenizePseudo("hover").length).toEqual(1);
|
||||
expect(tokenizePseudo("focus").length).toEqual(1);
|
||||
|
||||
expect(() => { tokenizePseudo('lang(something:broken)'); }).toThrow();
|
||||
expect(() => { tokenizePseudo("lang(something:broken)"); }).toThrow();
|
||||
|
||||
expect(() => { tokenizePseudo('not(.selector)'); }).toThrow();
|
||||
expect(() => { tokenizePseudo("not(.selector)"); }).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@ -350,35 +362,32 @@ export function main() {
|
||||
return tokenize(code, false, CssLexerMode.PSEUDO_SELECTOR);
|
||||
}
|
||||
|
||||
expect(tokenizePseudo('lang(en-us)').length).toEqual(4);
|
||||
expect(tokenizePseudo('hover').length).toEqual(1);
|
||||
expect(tokenizePseudo('focus').length).toEqual(1);
|
||||
expect(tokenizePseudo("lang(en-us)").length).toEqual(4);
|
||||
expect(tokenizePseudo("hover").length).toEqual(1);
|
||||
expect(tokenizePseudo("focus").length).toEqual(1);
|
||||
|
||||
expect(() => { tokenizePseudo('lang(something:broken)'); }).toThrow();
|
||||
expect(() => { tokenizePseudo("lang(something:broken)"); }).toThrow();
|
||||
|
||||
expect(() => { tokenizePseudo('not(.selector)'); }).toThrow();
|
||||
expect(() => { tokenizePseudo("not(.selector)"); }).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe(
|
||||
'Style Block Mode', () => {
|
||||
it('should style blocks with a reduced subset of valid characters',
|
||||
() => {
|
||||
function tokenizeStyles(code) {
|
||||
return tokenize(code, false, CssLexerMode.STYLE_BLOCK);
|
||||
}
|
||||
describe('Style Block Mode', () => {
|
||||
it('should style blocks with a reduced subset of valid characters', () => {
|
||||
function tokenizeStyles(code) { return tokenize(code, false, CssLexerMode.STYLE_BLOCK); }
|
||||
|
||||
expect(tokenizeStyles(`
|
||||
expect(tokenizeStyles(`
|
||||
key: value;
|
||||
prop: 100;
|
||||
style: value3!important;
|
||||
`).length).toEqual(14);
|
||||
`).length)
|
||||
.toEqual(14);
|
||||
|
||||
expect(() => tokenizeStyles(` key$: value; `)).toThrow();
|
||||
expect(() => tokenizeStyles(` key: value$; `)).toThrow();
|
||||
expect(() => tokenizeStyles(` key: value + 10; `)).toThrow();
|
||||
expect(() => tokenizeStyles(` key: &value; `)).toThrow();
|
||||
});
|
||||
});
|
||||
expect(() => tokenizeStyles(` key$: value; `)).toThrow();
|
||||
expect(() => tokenizeStyles(` key: value$; `)).toThrow();
|
||||
expect(() => tokenizeStyles(` key: value + 10; `)).toThrow();
|
||||
expect(() => tokenizeStyles(` key: &value; `)).toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -1,8 +1,35 @@
|
||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/testing_internal';
|
||||
import {
|
||||
ddescribe,
|
||||
describe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {BaseException} from 'angular2/src/facade/exceptions';
|
||||
|
||||
import {ParsedCssResult, CssParser, BlockType, CssSelectorRuleAST, CssKeyframeRuleAST, CssKeyframeDefinitionAST, CssBlockDefinitionRuleAST, CssMediaQueryRuleAST, CssBlockRuleAST, CssInlineRuleAST, CssStyleValueAST, CssSelectorAST, CssDefinitionAST, CssStyleSheetAST, CssRuleAST, CssBlockAST, CssParseError} from 'angular2/src/compiler/css/parser';
|
||||
import {
|
||||
ParsedCssResult,
|
||||
CssParser,
|
||||
BlockType,
|
||||
CssSelectorRuleAST,
|
||||
CssKeyframeRuleAST,
|
||||
CssKeyframeDefinitionAST,
|
||||
CssBlockDefinitionRuleAST,
|
||||
CssMediaQueryRuleAST,
|
||||
CssBlockRuleAST,
|
||||
CssInlineRuleAST,
|
||||
CssStyleValueAST,
|
||||
CssSelectorAST,
|
||||
CssDefinitionAST,
|
||||
CssStyleSheetAST,
|
||||
CssRuleAST,
|
||||
CssBlockAST,
|
||||
CssParseError
|
||||
} from 'angular2/src/compiler/css/parser';
|
||||
|
||||
import {CssLexer} from 'angular2/src/compiler/css/lexer';
|
||||
|
||||
@ -67,17 +94,17 @@ export function main() {
|
||||
var rule = <CssSelectorRuleAST>ast.rules[0];
|
||||
expect(rule.selectors.length).toBe(7);
|
||||
|
||||
assertTokens(rule.selectors[0].tokens, ['.', 'class']);
|
||||
assertTokens(rule.selectors[1].tokens, ['#', 'id']);
|
||||
assertTokens(rule.selectors[2].tokens, ['tag']);
|
||||
assertTokens(rule.selectors[3].tokens, ['[', 'attr', ']']);
|
||||
assertTokens(rule.selectors[4].tokens, ['key', ' ', '+', ' ', 'value']);
|
||||
assertTokens(rule.selectors[5].tokens, ['*', ' ', 'value']);
|
||||
assertTokens(rule.selectors[6].tokens, [':', '-moz-any-link']);
|
||||
assertTokens(rule.selectors[0].tokens, [".", "class"]);
|
||||
assertTokens(rule.selectors[1].tokens, ["#", "id"]);
|
||||
assertTokens(rule.selectors[2].tokens, ["tag"]);
|
||||
assertTokens(rule.selectors[3].tokens, ["[", "attr", "]"]);
|
||||
assertTokens(rule.selectors[4].tokens, ["key", " ", "+", " ", "value"]);
|
||||
assertTokens(rule.selectors[5].tokens, ["*", " ", "value"]);
|
||||
assertTokens(rule.selectors[6].tokens, [":", "-moz-any-link"]);
|
||||
|
||||
var style1 = <CssDefinitionAST>rule.block.entries[0];
|
||||
expect(style1.property.strValue).toEqual('prop');
|
||||
assertTokens(style1.value.tokens, ['value123']);
|
||||
expect(style1.property.strValue).toEqual("prop");
|
||||
assertTokens(style1.value.tokens, ["value123"]);
|
||||
});
|
||||
|
||||
it('should parse keyframe rules', () => {
|
||||
@ -160,16 +187,16 @@ export function main() {
|
||||
|
||||
var importRule = <CssInlineRuleAST>ast.rules[0];
|
||||
expect(importRule.type).toEqual(BlockType.Import);
|
||||
assertTokens(importRule.value.tokens, ['url', '(', 'remote', '.', 'css', ')']);
|
||||
assertTokens(importRule.value.tokens, ["url", "(", "remote", ".", "css", ")"]);
|
||||
|
||||
var charsetRule = <CssInlineRuleAST>ast.rules[1];
|
||||
expect(charsetRule.type).toEqual(BlockType.Charset);
|
||||
assertTokens(charsetRule.value.tokens, ['UTF-8']);
|
||||
assertTokens(charsetRule.value.tokens, ["UTF-8"]);
|
||||
|
||||
var namespaceRule = <CssInlineRuleAST>ast.rules[2];
|
||||
expect(namespaceRule.type).toEqual(BlockType.Namespace);
|
||||
assertTokens(
|
||||
namespaceRule.value.tokens, ['ng', 'url', '(', 'http://angular.io/namespace/ng', ')']);
|
||||
assertTokens(namespaceRule.value.tokens,
|
||||
["ng", "url", "(", "http://angular.io/namespace/ng", ")"]);
|
||||
});
|
||||
|
||||
it('should parse CSS values that contain functions and leave the inner function data untokenized',
|
||||
@ -189,9 +216,8 @@ export function main() {
|
||||
expect(defs.length).toEqual(3);
|
||||
|
||||
assertTokens((<CssDefinitionAST>defs[0]).value.tokens, ['url', '(', 'matias.css', ')']);
|
||||
assertTokens(
|
||||
(<CssDefinitionAST>defs[1]).value.tokens,
|
||||
['cubic-bezier', '(', '0.755, 0.050, 0.855, 0.060', ')']);
|
||||
assertTokens((<CssDefinitionAST>defs[1]).value.tokens,
|
||||
['cubic-bezier', '(', '0.755, 0.050, 0.855, 0.060', ')']);
|
||||
assertTokens((<CssDefinitionAST>defs[2]).value.tokens, ['calc', '(', '100% - 50px', ')']);
|
||||
});
|
||||
|
||||
@ -239,7 +265,7 @@ export function main() {
|
||||
|
||||
var importRule = <CssInlineRuleAST>ast.rules[0];
|
||||
expect(importRule.type).toEqual(BlockType.Import);
|
||||
assertTokens(importRule.value.tokens, ['url', '(', 'something something', ')']);
|
||||
assertTokens(importRule.value.tokens, ["url", "(", "something something", ")"]);
|
||||
|
||||
var fontFaceRule = <CssBlockRuleAST>ast.rules[1];
|
||||
expect(fontFaceRule.type).toEqual(BlockType.FontFace);
|
||||
@ -304,7 +330,7 @@ export function main() {
|
||||
expect(documentRule.type).toEqual(BlockType.Document);
|
||||
|
||||
var rule = <CssSelectorRuleAST>documentRule.block.entries[0];
|
||||
expect(rule.strValue).toEqual('body');
|
||||
expect(rule.strValue).toEqual("body");
|
||||
});
|
||||
|
||||
it('should parse the @page rule', () => {
|
||||
@ -322,11 +348,11 @@ export function main() {
|
||||
var rules = ast.rules;
|
||||
|
||||
var pageRule1 = <CssBlockDefinitionRuleAST>rules[0];
|
||||
expect(pageRule1.strValue).toEqual('one');
|
||||
expect(pageRule1.strValue).toEqual("one");
|
||||
expect(pageRule1.type).toEqual(BlockType.Page);
|
||||
|
||||
var pageRule2 = <CssBlockDefinitionRuleAST>rules[1];
|
||||
expect(pageRule2.strValue).toEqual('two');
|
||||
expect(pageRule2.strValue).toEqual("two");
|
||||
expect(pageRule2.type).toEqual(BlockType.Page);
|
||||
|
||||
var selectorOne = <CssSelectorRuleAST>pageRule1.block.entries[0];
|
||||
@ -382,15 +408,15 @@ export function main() {
|
||||
expect(ast.rules.length).toEqual(3);
|
||||
|
||||
var rule1 = <CssSelectorRuleAST>ast.rules[0];
|
||||
expect(rule1.selectors[0].strValue).toEqual('tag&');
|
||||
expect(rule1.selectors[0].strValue).toEqual("tag&");
|
||||
expect(rule1.block.entries.length).toEqual(1);
|
||||
|
||||
var rule2 = <CssSelectorRuleAST>ast.rules[1];
|
||||
expect(rule2.selectors[0].strValue).toEqual('.%tag');
|
||||
expect(rule2.selectors[0].strValue).toEqual(".%tag");
|
||||
expect(rule2.block.entries.length).toEqual(1);
|
||||
|
||||
var rule3 = <CssSelectorRuleAST>ast.rules[2];
|
||||
expect(rule3.selectors[0].strValue).toEqual('#tag$');
|
||||
expect(rule3.selectors[0].strValue).toEqual("#tag$");
|
||||
expect(rule3.block.entries.length).toEqual(1);
|
||||
});
|
||||
|
||||
|
@ -1,9 +1,39 @@
|
||||
import {ddescribe, describe, it, iit, xit, expect, beforeEach, afterEach} from 'angular2/testing_internal';
|
||||
import {
|
||||
ddescribe,
|
||||
describe,
|
||||
it,
|
||||
iit,
|
||||
xit,
|
||||
expect,
|
||||
beforeEach,
|
||||
afterEach
|
||||
} from 'angular2/testing_internal';
|
||||
|
||||
import {NumberWrapper, StringWrapper, isPresent} from 'angular2/src/facade/lang';
|
||||
import {NumberWrapper, StringWrapper, isPresent} from "angular2/src/facade/lang";
|
||||
import {BaseException} from 'angular2/src/facade/exceptions';
|
||||
|
||||
import {CssToken, CssParser, CssParseError, BlockType, CssAST, CssSelectorRuleAST, CssKeyframeRuleAST, CssKeyframeDefinitionAST, CssBlockDefinitionRuleAST, CssMediaQueryRuleAST, CssBlockRuleAST, CssInlineRuleAST, CssStyleValueAST, CssSelectorAST, CssDefinitionAST, CssStyleSheetAST, CssRuleAST, CssBlockAST, CssASTVisitor, CssUnknownTokenListAST} from 'angular2/src/compiler/css/parser';
|
||||
import {
|
||||
CssToken,
|
||||
CssParser,
|
||||
CssParseError,
|
||||
BlockType,
|
||||
CssAST,
|
||||
CssSelectorRuleAST,
|
||||
CssKeyframeRuleAST,
|
||||
CssKeyframeDefinitionAST,
|
||||
CssBlockDefinitionRuleAST,
|
||||
CssMediaQueryRuleAST,
|
||||
CssBlockRuleAST,
|
||||
CssInlineRuleAST,
|
||||
CssStyleValueAST,
|
||||
CssSelectorAST,
|
||||
CssDefinitionAST,
|
||||
CssStyleSheetAST,
|
||||
CssRuleAST,
|
||||
CssBlockAST,
|
||||
CssASTVisitor,
|
||||
CssUnknownTokenListAST
|
||||
} from 'angular2/src/compiler/css/parser';
|
||||
|
||||
import {CssLexer} from 'angular2/src/compiler/css/lexer';
|
||||
|
||||
@ -23,49 +53,49 @@ class MyVisitor implements CssASTVisitor {
|
||||
|
||||
constructor(ast: CssStyleSheetAST, context?: any) { ast.visit(this, context); }
|
||||
|
||||
visitCssValue(ast, context?: any): void { this._capture('visitCssValue', ast, context); }
|
||||
visitCssValue(ast, context?: any): void { this._capture("visitCssValue", ast, context); }
|
||||
|
||||
visitInlineCssRule(ast, context?: any): void {
|
||||
this._capture('visitInlineCssRule', ast, context);
|
||||
this._capture("visitInlineCssRule", ast, context);
|
||||
}
|
||||
|
||||
visitCssKeyframeRule(ast: CssKeyframeRuleAST, context?: any): void {
|
||||
this._capture('visitCssKeyframeRule', ast, context);
|
||||
this._capture("visitCssKeyframeRule", ast, context);
|
||||
ast.block.visit(this, context);
|
||||
}
|
||||
|
||||
visitCssKeyframeDefinition(ast: CssKeyframeDefinitionAST, context?: any): void {
|
||||
this._capture('visitCssKeyframeDefinition', ast, context);
|
||||
this._capture("visitCssKeyframeDefinition", ast, context);
|
||||
ast.block.visit(this, context);
|
||||
}
|
||||
|
||||
visitCssMediaQueryRule(ast: CssMediaQueryRuleAST, context?: any): void {
|
||||
this._capture('visitCssMediaQueryRule', ast, context);
|
||||
this._capture("visitCssMediaQueryRule", ast, context);
|
||||
ast.block.visit(this, context);
|
||||
}
|
||||
|
||||
visitCssSelectorRule(ast: CssSelectorRuleAST, context?: any): void {
|
||||
this._capture('visitCssSelectorRule', ast, context);
|
||||
this._capture("visitCssSelectorRule", ast, context);
|
||||
ast.selectors.forEach((selAST: CssSelectorAST) => { selAST.visit(this, context); });
|
||||
ast.block.visit(this, context);
|
||||
}
|
||||
|
||||
visitCssSelector(ast: CssSelectorAST, context?: any): void {
|
||||
this._capture('visitCssSelector', ast, context);
|
||||
this._capture("visitCssSelector", ast, context);
|
||||
}
|
||||
|
||||
visitCssDefinition(ast: CssDefinitionAST, context?: any): void {
|
||||
this._capture('visitCssDefinition', ast, context);
|
||||
this._capture("visitCssDefinition", ast, context);
|
||||
ast.value.visit(this, context);
|
||||
}
|
||||
|
||||
visitCssBlock(ast: CssBlockAST, context?: any): void {
|
||||
this._capture('visitCssBlock', ast, context);
|
||||
this._capture("visitCssBlock", ast, context);
|
||||
ast.entries.forEach((entryAST: CssAST) => { entryAST.visit(this, context); });
|
||||
}
|
||||
|
||||
visitCssStyleSheet(ast: CssStyleSheetAST, context?: any): void {
|
||||
this._capture('visitCssStyleSheet', ast, context);
|
||||
this._capture("visitCssStyleSheet", ast, context);
|
||||
ast.rules.forEach((ruleAST: CssRuleAST) => { ruleAST.visit(this, context); });
|
||||
}
|
||||
|
||||
@ -178,7 +208,7 @@ export function main() {
|
||||
expect(captures.length).toEqual(1);
|
||||
|
||||
var query1 = <CssMediaQueryRuleAST>captures[0][0];
|
||||
_assertTokens(query1.query, ['all', 'and', '(', 'max-width', '100', 'px', ')']);
|
||||
_assertTokens(query1.query, ["all", "and", "(", "max-width", "100", "px", ")"]);
|
||||
expect(query1.block.entries.length).toEqual(1);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user