Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Unified Diff: pkg/polymer/lib/src/declaration.dart

Issue 60353013: Update TodoMVC based on https://github.com/polymer/todomvc (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix pubspecs Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/polymer/lib/src/declaration.dart
diff --git a/pkg/polymer/lib/src/declaration.dart b/pkg/polymer/lib/src/declaration.dart
index 84dbc1ae5380a29438013f6638a2ed5ae0c09f0d..252807df9e8b540f6a6324fecff565d5587056a7 100644
--- a/pkg/polymer/lib/src/declaration.dart
+++ b/pkg/polymer/lib/src/declaration.dart
@@ -363,7 +363,7 @@ class PolymerDeclaration extends HtmlElement {
void installLocalSheets() {
var sheets = this.sheets.where(
(s) => !s.attributes.containsKey(_SCOPE_ATTR));
- var content = this.templateContent;
+ var content = templateContent;
if (content != null) {
var cssText = new StringBuffer();
for (var sheet in sheets) {
@@ -378,8 +378,8 @@ class PolymerDeclaration extends HtmlElement {
}
List<Element> findNodes(String selector, [bool matcher(Element e)]) {
- var nodes = this.queryAll(selector).toList();
- var content = this.templateContent;
+ var nodes = this.querySelectorAll(selector).toList();
+ var content = templateContent;
if (content != null) {
nodes = nodes..addAll(content.queryAll(selector));
}
@@ -569,11 +569,38 @@ const _STYLE_SCOPE_ATTRIBUTE = 'element';
const _STYLE_CONTROLLER_SCOPE = 'controller';
String _cssTextFromSheet(Element sheet) {
- if (sheet == null || js.context == null) return '';
- var resource = new js.JsObject.fromBrowserObject(sheet)['__resource'];
- return resource != null ? resource : '';
+ if (sheet == null) return '';
+
+ // TODO(jmesserly): sometimes the href property is wrong after deployment.
+ var href = sheet.href;
+ if (href == '') href = sheet.attributes["href"];
+
+ if (js.context != null && js.context.hasProperty('HTMLImports')) {
+ var jsSheet = new js.JsObject.fromBrowserObject(sheet);
+ var resource = jsSheet['__resource'];
+ if (resource != null) return resource;
+ _sheetLog.fine('failed to get stylesheet text href="$href"');
+ return '';
+ }
+ // TODO(jmesserly): it seems like polymer-js is always polyfilling
+ // HTMLImports, because their code depends on "__resource" to work.
+ // We work around this by using a sync XHR to get the stylesheet text.
+ // Right now this code is only used in Dartium, but if it's going to stick
+ // around we will need to find a different approach.
+ try {
+ return (new HttpRequest()
+ ..open('GET', href, async: false)
+ ..send())
+ .responseText;
+ } on DomException catch (e, t) {
+ _sheetLog.fine('failed to get stylesheet text href="$href" error: '
+ '$e, trace: $t');
+ return '';
+ }
}
+final Logger _sheetLog = new Logger('polymer.stylesheet');
+
const _OBSERVE_SUFFIX = 'Changed';
// TODO(jmesserly): is this list complete?

Powered by Google App Engine
This is Rietveld 408576698