jifalops / mdc_web

Dart wrapper for the material-components-web javascript library.
MIT License
18 stars 6 forks source link

Error while running demo #2

Open e-belair opened 5 years ago

e-belair commented 5 years ago

Hi, I get this error in console when I load the demo app:

Uncaught TypeError: Failed to execute 'define' on 'CustomElementRegistry': constructor argument is not a constructor
    at main$ (main.dart:50)
    at main$.next (<anonymous>)
    at onValue (dart_sdk.js:21834)
    at async._RootZone.new.runUnary (dart_sdk.js:27963)
    at _FutureListener.then.handleValue (dart_sdk.js:23730)
    at handleValueCallback (dart_sdk.js:24192)
    at Function._propagateToListeners (dart_sdk.js:24222)
    at _Future.new.[_complete] (dart_sdk.js:24076)
    at listen.onDone.dart.fn (dart_sdk.js:10477)
    at async._RootZone.new.runGuarded (dart_sdk.js:27896)
    at _ControllerSubscription.new.<anonymous> (dart_sdk.js:22464)
    at _ControllerSubscription.new.[_sendDone] (dart_sdk.js:22473)
    at async._DelayedDone.new.perform (dart_sdk.js:25587)
    at _StreamImplEvents.new.handleNext (dart_sdk.js:25634)
    at async._AsyncCallbackEntry.new.async.scheduleMicrotask.dart.fn [as callback] (dart_sdk.js:25412)
    at Object.async._microtaskLoop (dart_sdk.js:24434)
    at async._startMicrotaskLoop (dart_sdk.js:24440)
    at MutationObserver.internalCallback (dart_sdk.js:24510)
jifalops commented 5 years ago

There is a bug in dart:html where it can only register components in release mode (it is still based on web components v0). One of the demos does attempt to register a component but it warns about the issue. This mdc_web Dart package is meant to be used with the component reference, which uses BEM notation, a verbose way of using the HTML class attribute that allows better scalability of CSS styling.

There is another layer in the works to provide custom elements build on MDC Web, https://github.com/material-components/material-components-web-components. I plan on making a similar package for Dart in the future that uses it, similar to how this package uses the underlying Javascript version of MDC Web.