Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 9a369e3

Browse files
vicbrkirov
authored andcommitted
fix(css_shim): allow "..." for content
fixes #1565
1 parent ac4bc17 commit 9a369e3

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

lib/core_dom/css_shim.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ class _CssShim {
5454

5555
static final RegExp CONTENT = new RegExp(
5656
r"[^}]*"
57-
r"content\:[\s]*"
58-
r"'([^']*)'"
57+
r"content:\s*"
58+
"('|\")([^\\1]*)\\1"
5959
r"[^}]*}",
6060
caseSensitive: false,
6161
multiLine: true
6262
);
6363

6464
static final String HOST_TOKEN = '-host-element';
65-
static final RegExp COLON_SELECTORS = new RegExp(r'(' + HOST_TOKEN + r')(\(.*\)){0,1}(.*)',
65+
static final RegExp COLON_SELECTORS = new RegExp(r'(' + HOST_TOKEN + r')(\(.*\))?(.*)',
6666
caseSensitive: false);
6767
static final RegExp SIMPLE_SELECTORS = new RegExp(r'([^:]*)(:*)(.*)', caseSensitive: false);
6868
static final RegExp IS_SELECTORS = new RegExp(r'\[is="([^\]]*)"\]', caseSensitive: false);
@@ -152,7 +152,7 @@ class _CssShim {
152152
}
153153

154154
String extractContent(_Rule rule) {
155-
return CONTENT.firstMatch(rule.body)[1];
155+
return CONTENT.firstMatch(rule.body)[2];
156156
}
157157

158158
String ruleToString(_Rule rule) {
@@ -412,4 +412,4 @@ class _Parser {
412412

413413
_Token get current => tokens[currentIndex];
414414
_Token get next => tokens[currentIndex + 1];
415-
}
415+
}

test/core_dom/css_shim_spec.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ library css_shim_spec;
22

33
import '../_specs.dart';
44
import 'package:angular/core_dom/css_shim.dart';
5-
import 'dart:html' as dom;
65

76
main() {
87
describe("cssShim", () {
@@ -78,11 +77,17 @@ main() {
7877
it("should support polyfill-next-selector", () {
7978
var css = s("polyfill-next-selector {content: 'x > y'} z {}", "a");
8079
expect(css).toEqual('x[a]>y[a] {}');
80+
81+
css = s('polyfill-next-selector {content: "x > y"} z {}', "a");
82+
expect(css).toEqual('x[a]>y[a] {}');
8183
});
8284

8385
it("should support polyfill-unscoped-next-selector", () {
8486
var css = s("polyfill-unscoped-next-selector {content: 'x > y'} z {}", "a");
8587
expect(css).toEqual('x > y {}');
88+
89+
css = s('polyfill-unscoped-next-selector {content: "x > y"} z {}', "a");
90+
expect(css).toEqual('x > y {}');
8691
});
8792

8893
it("should support polyfill-non-strict-next-selector", () {
@@ -100,4 +105,4 @@ main() {
100105
expect(css).toEqual('a x y {}');
101106
});
102107
});
103-
}
108+
}

0 commit comments

Comments
 (0)