Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

DO NOT MERGE: add noSuchMethod proxying to the js element #76

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions example/core_drawer_panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@
import 'package:polymer/polymer.dart';
export 'package:polymer/init.dart' show main;

_js(x) => new JsObject.fromBrowserObject(x);

@initMethod init() {
querySelector('div[main] > button').onClick.listen((_) {
_js(querySelector('core-drawer-panel')).callMethod('togglePanel');
querySelector('core-drawer-panel').togglePanel();
});
}
</script>
Expand Down
16 changes: 15 additions & 1 deletion lib/core_animated_pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_animated_pages;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'core_selector.dart';
Expand Down Expand Up @@ -223,6 +224,19 @@ class CoreAnimatedPages extends CoreSelector {
/// on incoming and outgoing pages.
get lastSelected => jsElement['lastSelected'];
set lastSelected(value) { jsElement['lastSelected'] = (value is Map || value is Iterable) ? new JsObject.jsify(value) : value;}

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreAnimatedPages() => registerDartType('core-animated-pages', CoreAnimatedPages);
42 changes: 41 additions & 1 deletion lib/core_animation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_animation;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'package:core_elements/src/common.dart' show DomProxyMixin;
Expand Down Expand Up @@ -200,6 +201,19 @@ class CoreAnimation extends HtmlElement with DomProxyMixin {
/// plays it if autoplay is true.
apply() =>
jsElement.callMethod('apply', []);

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreAnimation() => registerDartType('core-animation', CoreAnimation);
Expand All @@ -219,6 +233,19 @@ class CoreAnimationKeyframe extends HtmlElement with DomProxyMixin {
set offset(value) { jsElement['offset'] = (value is Map || value is Iterable) ? new JsObject.jsify(value) : value;}

get properties => jsElement['properties'];

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreAnimationKeyframe() => registerDartType('core-animation-keyframe', CoreAnimationKeyframe);
Expand All @@ -237,6 +264,19 @@ class CoreAnimationProp extends HtmlElement with DomProxyMixin {
/// The value for the CSS property.
get value => jsElement['value'];
set value(value) { jsElement['value'] = (value is Map || value is Iterable) ? new JsObject.jsify(value) : value;}

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreAnimationProp() => registerDartType('core-animation-prop', CoreAnimationProp);
16 changes: 15 additions & 1 deletion lib/core_animation_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_animation_group;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'core_animation.dart';
Expand Down Expand Up @@ -54,6 +55,19 @@ class CoreAnimationGroup extends CoreAnimation {
get childAnimationElements => jsElement['childAnimationElements'];

get childAnimations => jsElement['childAnimations'];

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreAnimationGroup() => registerDartType('core-animation-group', CoreAnimationGroup);
16 changes: 15 additions & 1 deletion lib/core_collapse.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_collapse;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'package:core_elements/src/common.dart' show DomProxyMixin;
Expand Down Expand Up @@ -52,6 +53,19 @@ class CoreCollapse extends HtmlElement with DomProxyMixin {
/// Toggle the opened state.
void toggle() =>
jsElement.callMethod('toggle', []);

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreCollapse() => registerDartType('core-collapse', CoreCollapse);
16 changes: 15 additions & 1 deletion lib/core_drag_drop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,28 @@
library core_elements.core_drag_drop;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'package:core_elements/src/common.dart' show DomProxyMixin;


class CoreDragDrop extends HtmlElement with DomProxyMixin {
CoreDragDrop.created() : super.created();

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreDragDrop() => registerDartType('core-drag-drop', CoreDragDrop);
16 changes: 15 additions & 1 deletion lib/core_drawer_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_drawer_panel;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'package:core_elements/src/common.dart' show DomProxyMixin;
Expand Down Expand Up @@ -53,6 +54,19 @@ class CoreDrawerPanel extends HtmlElement with DomProxyMixin {
/// need to show/hide elements based on the layout.
bool get narrow => jsElement['narrow'];
set narrow(bool value) { jsElement['narrow'] = value; }

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreDrawerPanel() => registerDartType('core-drawer-panel', CoreDrawerPanel);
16 changes: 15 additions & 1 deletion lib/core_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_field;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'package:core_elements/src/common.dart' show DomProxyMixin;
Expand All @@ -20,6 +21,19 @@ import 'package:core_elements/src/common.dart' show DomProxyMixin;
/// </core-field>
class CoreField extends HtmlElement with DomProxyMixin {
CoreField.created() : super.created();

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreField() => registerDartType('core-field', CoreField);
16 changes: 15 additions & 1 deletion lib/core_header_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_header_panel;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'package:core_elements/src/common.dart' show DomProxyMixin;
Expand Down Expand Up @@ -112,6 +113,19 @@ class CoreHeaderPanel extends HtmlElement with DomProxyMixin {
get header => jsElement['header'];

get scroller => jsElement['scroller'];

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreHeaderPanel() => registerDartType('core-header-panel', CoreHeaderPanel);
16 changes: 15 additions & 1 deletion lib/core_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_icon;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'package:core_elements/src/common.dart' show DomProxyMixin;
Expand Down Expand Up @@ -48,6 +49,19 @@ class CoreIcon extends HtmlElement with DomProxyMixin {
/// the src property should not be.
String get icon => jsElement['icon'];
set icon(String value) { jsElement['icon'] = value; }

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreIcon() => registerDartType('core-icon', CoreIcon);
16 changes: 15 additions & 1 deletion lib/core_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_icon_button;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'package:core_elements/src/common.dart' show DomProxyMixin;
Expand Down Expand Up @@ -38,6 +39,19 @@ class CoreIconButton extends HtmlElement with DomProxyMixin {
/// active state.
bool get active => jsElement['active'];
set active(bool value) { jsElement['active'] = value; }

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreIconButton() => registerDartType('core-icon-button', CoreIconButton);
3 changes: 2 additions & 1 deletion lib/core_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_icons;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;

16 changes: 15 additions & 1 deletion lib/core_iconset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
library core_elements.core_iconset;

import 'dart:html';
import 'dart:js' show JsArray, JsObject;
import 'dart:js' show JsArray, JsObject, JsFunction;
import 'dart:mirrors';
import 'package:web_components/interop.dart' show registerDartType;
import 'package:polymer/polymer.dart' show initMethod;
import 'core_meta.dart';
Expand Down Expand Up @@ -109,6 +110,19 @@ class CoreIconset extends CoreMeta {
/// with which the icon can be magnified.
void applyIcon(element,icon,String theme,scale) =>
jsElement.callMethod('applyIcon', [element,icon,theme,scale]);

noSuchMethod(Invocation invocation) {
String methodName = MirrorSystem.getName(invocation.memberName);
if (invocation.isMethod && jsElement[methodName] is JsFunction) {
print('Warning, passing missing method call ${methodName} to '
'JS element. This may impact performance, and should be wrapped '
'explicitely in dart.');
jsElement.callMethod(
methodName, invocation.positionalArguments);
} else {
super.noSuchMethod(invocation);
}
}
}
@initMethod
upgradeCoreIconset() => registerDartType('core-iconset', CoreIconset);
Loading