Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text field demo site has "Uncaught ReferenceError: mdc is not defined" error #1808

Closed
lynnmercier opened this issue Dec 20, 2017 · 2 comments
Labels

Comments

@lynnmercier
Copy link
Contributor

screen shot 2017-12-19 at 4 51 37 pm

@anton-kachurin
Copy link
Contributor

I came across this issue when looking at #1529
It is unclear to me why this happens. For me, it happens in about 50% cases when the page loads from localhost, and never - when loading the demo site. I only tried it on Chrome, Windows 10.

The issue above has the following comment:

CodePen (TIMING DEPENDENT - may be hard to repro on a slow website with lots of external network fetches like CodePen. Repros reliably on my local demo server.)

The issue could be a result of how webpack works internally, or it could be a result of how browsers process script tags.

Regardless of the root of the problem, I believe the Text Field demo needs to be rewritten. It uses a <script>setTimeout(function(){//code using window.mdc object}, 0)</script> before the following script loads MDC library. This is not by any means how things should be done in production or development. Moving MDC script into <head> is one solution. Another one is to rely on document.addEventListener("DOMContentLoaded", () => {}) instead of setTimeout(()=>{}, 0). Or move everything to the bottom of the <body> but put the MDC library loader first.

@acdvorak
Copy link
Contributor

This should be fixed by #1919 and #1920

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants