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

Side by Side Diff: pkg/polymer/lib/src/declaration.dart

Issue 31423002: fix Polymer to work with latest JS interop (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/pkg.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 596
597 var shadowCss = platform['ShadowCSS']; 597 var shadowCss = platform['ShadowCSS'];
598 if (shadowCss == null) return; 598 if (shadowCss == null) return;
599 599
600 // TODO(terry): Remove calls to shimShadowDOMStyling2 and replace with 600 // TODO(terry): Remove calls to shimShadowDOMStyling2 and replace with
601 // shimShadowDOMStyling when we support unwrapping dart:html 601 // shimShadowDOMStyling when we support unwrapping dart:html
602 // Element to a JS DOM node. 602 // Element to a JS DOM node.
603 var shimShadowDOMStyling2 = shadowCss['shimShadowDOMStyling2']; 603 var shimShadowDOMStyling2 = shadowCss['shimShadowDOMStyling2'];
604 if (shimShadowDOMStyling2 == null) return; 604 if (shimShadowDOMStyling2 == null) return;
605 605
606 var scopedCSS = shimShadowDOMStyling2.apply(shadowCss, 606 var scopedCSS = shimShadowDOMStyling2.apply([style.text, localName],
607 [style.text, localName]); 607 thisArg: shadowCss);
608 608
609 // TODO(terry): Remove when shimShadowDOMStyling is called we don't need to 609 // TODO(terry): Remove when shimShadowDOMStyling is called we don't need to
610 // replace original CSS with scoped CSS shimShadowDOMStyling 610 // replace original CSS with scoped CSS shimShadowDOMStyling
611 // does that. 611 // does that.
612 style.text = scopedCSS; 612 style.text = scopedCSS;
613 } 613 }
614 614
615 const _STYLE_SELECTOR = 'style'; 615 const _STYLE_SELECTOR = 'style';
616 const _SHEET_SELECTOR = '[rel=stylesheet]'; 616 const _SHEET_SELECTOR = '[rel=stylesheet]';
617 const _STYLE_GLOBAL_SCOPE = 'global'; 617 const _STYLE_GLOBAL_SCOPE = 'global';
(...skipping 13 matching lines...) Expand all
631 var attr = style.attributes[_STYLE_SCOPE_ATTRIBUTE]; 631 var attr = style.attributes[_STYLE_SCOPE_ATTRIBUTE];
632 if (attr != null) { 632 if (attr != null) {
633 clone.attributes[_STYLE_SCOPE_ATTRIBUTE] = attr; 633 clone.attributes[_STYLE_SCOPE_ATTRIBUTE] = attr;
634 } 634 }
635 635
636 scope.append(clone); 636 scope.append(clone);
637 } 637 }
638 638
639 String _cssTextFromSheet(Element sheet) { 639 String _cssTextFromSheet(Element sheet) {
640 if (sheet == null || js.context == null) return ''; 640 if (sheet == null || js.context == null) return '';
641 641 var resource = new JsObject.fromBrowserObject(sheet)['__resource'];
642 // TODO(jmesserly): this is a hacky way to communcate with HTMLImports...
643
644 // Remove rel=stylesheet, href to keep this inert.
645 var href = sheet.attributes.remove('href');
646 var rel = sheet.attributes.remove('rel');
647 document.body.append(sheet);
648 String resource;
649 try {
650 resource = js.context['document']['body']['lastChild']['__resource'];
651 } finally {
652 sheet.remove();
653 if (href != null) sheet.attributes['href'] = href;
654 if (rel != null) sheet.attributes['rel'] = rel;
655 }
656 return resource != null ? resource : ''; 642 return resource != null ? resource : '';
657 } 643 }
658 644
659 const _OBSERVE_SUFFIX = 'Changed'; 645 const _OBSERVE_SUFFIX = 'Changed';
660 646
661 // TODO(jmesserly): is this list complete? 647 // TODO(jmesserly): is this list complete?
662 final _eventTranslations = const { 648 final _eventTranslations = const {
663 // TODO(jmesserly): these three Polymer.js translations won't work in Dart, 649 // TODO(jmesserly): these three Polymer.js translations won't work in Dart,
664 // because we strip the webkit prefix (below). Reconcile. 650 // because we strip the webkit prefix (below). Reconcile.
665 'webkitanimationstart': 'webkitAnimationStart', 651 'webkitanimationstart': 'webkitAnimationStart',
(...skipping 25 matching lines...) Expand all
691 return map; 677 return map;
692 }(); 678 }();
693 679
694 // Dart note: we need this function because we have additional renames JS does 680 // Dart note: we need this function because we have additional renames JS does
695 // not have. The JS renames are simply case differences, whereas we have ones 681 // not have. The JS renames are simply case differences, whereas we have ones
696 // like doubleclick -> dblclick and stripping the webkit prefix. 682 // like doubleclick -> dblclick and stripping the webkit prefix.
697 String _eventNameFromType(String eventType) { 683 String _eventNameFromType(String eventType) {
698 final result = _reverseEventTranslations[eventType]; 684 final result = _reverseEventTranslations[eventType];
699 return result != null ? result : eventType; 685 return result != null ? result : eventType;
700 } 686 }
OLDNEW
« no previous file with comments | « pkg/pkg.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698