I am seeing this error in my console:
Exception: InvalidStateError: Internal Dartium Exception
PolymerDeclaration.registerType (package:polymer/src/declaration.dart:241:22)
PolymerDeclaration.register (package:polymer/src/declaration.dart:175:17)
PolymerDeclaration._register (package:polymer/src/declaration.dart:114:13)
PolymerDeclaration.registerWhenReady (package:polymer/src/declaration.dart:109:14)
_notifyType (package:polymer/src/declaration.dart:514:49)
Polymer.register (package:polymer/src/instance.dart:64:16)
_loadLibrary (package:polymer/src/loader.dart:177:25)
I have code like this:
#CustomTag('person-tag')
class PersonTag extends PolymerElement {
And my HTML is like this:
<polymer-element name="person-tag" extends="li">
Why am I getting this Internal Dartium Exception error from registerType ?
You are seeing this error because your HTML says extends="li" but the Dart code only extends PolymerElement.
If you use an extends attribute in your polymer-element, then your Dart class must also extend the same kind of element.
To fix the problem in the question, change the Dart class:
#CustomTag('person-tag')
class PersonTag extends LIElement with Polymer, Observable {
Now PersonTag really does extend <li>.
Related
I am getting the following error in my Apploader. I don't know from where ConfigurationComponents is getting included in my code.
Error:(63, 7) class AppComponents inherits conflicting members:
method configuration in class BuiltInComponentsFromContext of type => play.api.Configuration and
method configuration in trait ConfigurationComponents of type ()play.api.Configuration
(Note: this can be resolved by declaring an override in class AppComponents.);
other members with override errors are: environment, applicationLifecycle, httpErrorHandler, fileMimeTypes
class AppComponents (context: Context) extends BuiltInComponentsFromContext(context)
Also, I dont understand the statement in the above error other members with override errors are: environment, applicationLifecycle, httpErrorHandler, fileMimeTypes
Snippet of my Apploader.scala code is
class AppComponents (context: Context) extends BuiltInComponentsFromContext(context)
with CassandraRepositoryComponents
with HttpFiltersComponents
with AssetsComponents
with CSRFComponents { ... }
I also notice that the different use of () and => in the statement => play.api.Configuration and method configuration in trait ConfigurationComponents of type ()play.api.Configuration
The issue got resolved when I removed import play.controllers.AssetsComponents. It seems I included this file by mistake which caused conflicts.
So i've been trying to add a PolymerElement dynamically to an other PolymerElement.
MyPolyElem newRow = new MyPolyElem();
(newRow as MyPolyElem).type = type; // -> Exception
panelBody.append(newRow);
Exception: Uncaught Error: type 'HtmlElement' is not a subtype of type 'MyPolyElem ' in type cast.
If I try to access type, it says that newRow is a HtmlElement and does not have "type". If I try to cast it, is says that its not a subtype of HtmlElement.
#CustomTag('poly-elem')
class MyPolyElem extends PolymerElement {
#published String type = "int";
void attached() {
super.attached();
}
factory MyPolyElem() => document.createElement("poly-elem");
MyPolyElem.created() : super.created() {}
}
Apparently, if i create a Polymer Element dynamically, its a HtmlElement. If i would write in the the HTML as tag and query for it, its a MyPolyElem. So i'd like to know how i could register the Name of the Class for this Tag.
Dynamically created elements can be cast like declaratively added elements.
I'm pretty sure this doesn't work in your case because Polymer is not yet fully initialized.
See how to implement a main function in polymer apps for how to initialize Polymer properly when you have a custom main() method.
I never used document.createElement() to create a Polymer element dynamically. I used new Element.tag('xxx-yyy') instead. If the main() method is not the cause you might try this (see also Dynamically create polymer element)
Even though you create it dynamically you need to add an import like when you add it decoratively.
I'm trying to work through a Google I/O codelab for the Material Design Web App, but port it to the Dart language. http://io2014codelabs.appspot.com/static/codelabs/polymer-build-mobile/#4
I'm at the step where you toggle the drawer, but I can't figure out the dart equivalent.
The JS code to toggle the drawer looks like this:
<script>
Polymer('codelab-app', {
toggleDrawer: function() {
this.$.drawerPanel.togglePanel();
}
});
</script>
I have tried the following in my CodelabApp class, but I get a NoSuchMethodError: method not found: 'togglePanel'
#CustomTag('codelab-app')
class CodelabApp extends PolymerElement {
CodelabApp.created() : super.created() {}
void toggleDrawer() {
querySelector('core-drawer-panel')..togglePanel();
}
}
my button element properly fires, but I can't figure out how to call the drawer's togglePanel method. <paper-icon-button icon="menu" on-click="{{toggleDrawer}}"></paper-icon-button>
any help or direction to the proper docs would be greatly appreciated.
UPDATE:
This has been fixed in recent versions: https://github.com/dart-lang/core-elements/issues/39
Updating the polymer and core_elements libraries works as expected.
While attempting to commit my own fix to this, I discovered a temporary workaround that works in my case. Maybe will work for you :)
Add the following to the top of your file:
import 'dart:js' show JsObject;
_js(x) => new JsObject.fromBrowserObject(x);
Then change your custom tag code:
#CustomTag('codelab-app')
class CodelabApp extends PolymerElement {
CodelabApp.created() : super.created() {}
void toggleDrawer() {
_js(shadowRoot.querySelector('core-drawer-panel')).callMethod('togglePanel');
}
}
For reference I found this solution by reading through the code here:
https://github.com/dart-lang/core-elements/blob/master/example/core_drawer_panel.html#L68-L81
I am trying to create custom element using the following:
import 'package:polymer/polymer.dart';
// Custom elements extend PolymerElement
#CustomTag('my-element')
class MyElement extends PolymerElement {
// custom functionality goes here
}
Dart Editor shows error 'Undefined name CustomTag
I am trying the example given at the URL below. All files are copied as listed at the URL below.
https://github.com/sethladd/dart-polymer-dart-examples/blob/master/web/custom_element_that_contains_other_tags/my_element.dart
Am I missing something in pubspec? pubspec is not listed at the above URL.
I know we can use components with the admin generator (thanks to ~ symbol).
However, in the components.class.php, how to call the auto-generated class ?
At this moment, I'm using this :
require_once dirname(__FILE__).'/../lib/commissionGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/commissionGeneratorHelper.class.php';
class commissionComponents extends autoCommissionComponents
{
}
But I obtain this error :
Fatal error: Class 'autoCommissionComponents' not found in /home/site/liguelorraine/apps/saSecureLigueLorraine/modules/commission/actions/components.class.php on line 7
There are no automatically generated component classes. Just extends sfComponents as usual.