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

Fix undefined check #994

Closed
wants to merge 4 commits into from
Closed

Fix undefined check #994

wants to merge 4 commits into from

Conversation

marr
Copy link
Contributor

@marr marr commented Feb 21, 2020

Description

Dropdown was throwing because it was trying to invoke a method on M when M was undefined. Components don't work as expected without the M global defined. This should be added to the documentation:

window.M = require('materialize-css')

Without that, things like dropdowns don't work.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Copy link
Member

@alextrastero alextrastero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're actually trying to remove the check of typeof M undefined, since with this check it will fail in silence.

I would rather an error come up and knowing where to fix.

As per the documentation, it clearly states to add path/to/materialize.js before the bundle.

Of course an example for adding materialize to the current bundle as an es module would be great.

@alextrastero
Copy link
Member

Thanks for the contribution!

@marr marr closed this Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants