| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of polymer; | 5 part of polymer; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * **Warning**: this class is experiental and subject to change. | 8 * **Warning**: this class is experiental and subject to change. |
| 9 * | 9 * |
| 10 * The implementation for the `polymer-element` element. | 10 * The implementation for the `polymer-element` element. |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 const _STYLE_SCOPE_ATTRIBUTE = 'element'; | 651 const _STYLE_SCOPE_ATTRIBUTE = 'element'; |
| 652 const _STYLE_CONTROLLER_SCOPE = 'controller'; | 652 const _STYLE_CONTROLLER_SCOPE = 'controller'; |
| 653 | 653 |
| 654 String _cssTextFromSheet(LinkElement sheet) { | 654 String _cssTextFromSheet(LinkElement sheet) { |
| 655 if (sheet == null) return ''; | 655 if (sheet == null) return ''; |
| 656 | 656 |
| 657 // TODO(jmesserly): sometimes the href property is wrong after deployment. | 657 // TODO(jmesserly): sometimes the href property is wrong after deployment. |
| 658 var href = sheet.href; | 658 var href = sheet.href; |
| 659 if (href == '') href = sheet.attributes["href"]; | 659 if (href == '') href = sheet.attributes["href"]; |
| 660 | 660 |
| 661 // TODO(jmesserly): our build is not doing the right thing for |
| 662 // link rel=stylesheet, see http://dartbug.com/16648 |
| 661 if (js.context != null && js.context.hasProperty('HTMLImports')) { | 663 if (js.context != null && js.context.hasProperty('HTMLImports')) { |
| 662 var jsSheet = new js.JsObject.fromBrowserObject(sheet); | 664 var jsSheet = new js.JsObject.fromBrowserObject(sheet); |
| 663 var resource = jsSheet['__resource']; | 665 var resource = jsSheet['__resource']; |
| 664 if (resource != null) return resource; | 666 if (resource != null) return resource; |
| 665 _sheetLog.fine('failed to get stylesheet text href="$href"'); | 667 // TODO(jmesserly): figure out why HTMLImports is failing to load these. |
| 666 return ''; | 668 // Falling back to sync XHR is no good. |
| 669 // _sheetLog.fine('failed to get stylesheet text href="$href"'); |
| 670 // return ''; |
| 667 } | 671 } |
| 668 // TODO(jmesserly): it seems like polymer-js is always polyfilling | 672 // TODO(jmesserly): it seems like polymer-js is always polyfilling |
| 669 // HTMLImports, because their code depends on "__resource" to work. | 673 // HTMLImports, because their code depends on "__resource" to work. |
| 670 // We work around this by using a sync XHR to get the stylesheet text. | 674 // We work around this by using a sync XHR to get the stylesheet text. |
| 671 // Right now this code is only used in Dartium, but if it's going to stick | 675 // Right now this code is only used in Dartium, but if it's going to stick |
| 672 // around we will need to find a different approach. | 676 // around we will need to find a different approach. |
| 673 try { | 677 try { |
| 674 return (new HttpRequest() | 678 return (new HttpRequest() |
| 675 ..open('GET', href, async: false) | 679 ..open('GET', href, async: false) |
| 676 ..send()) | 680 ..send()) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 | 726 |
| 723 // Dart note: we need this function because we have additional renames JS does | 727 // Dart note: we need this function because we have additional renames JS does |
| 724 // not have. The JS renames are simply case differences, whereas we have ones | 728 // not have. The JS renames are simply case differences, whereas we have ones |
| 725 // like doubleclick -> dblclick and stripping the webkit prefix. | 729 // like doubleclick -> dblclick and stripping the webkit prefix. |
| 726 String _eventNameFromType(String eventType) { | 730 String _eventNameFromType(String eventType) { |
| 727 final result = _reverseEventTranslations[eventType]; | 731 final result = _reverseEventTranslations[eventType]; |
| 728 return result != null ? result : eventType; | 732 return result != null ? result : eventType; |
| 729 } | 733 } |
| 730 | 734 |
| 731 final _ATTRIBUTES_REGEX = new RegExp(r'\s|,'); | 735 final _ATTRIBUTES_REGEX = new RegExp(r'\s|,'); |
| OLD | NEW |