hotwired / stimulus

A modest JavaScript framework for the HTML you already have
https://stimulus.hotwired.dev/
MIT License
12.55k stars 420 forks source link

Error parsing descriptor string in markup inserted by third party plugins #114

Closed beghelli closed 6 years ago

beghelli commented 6 years ago

Hello, and thanks for this work, it's really awesome.

In my application I am using a jQuery plugin that is already using "data-action" in its markup, for a completely different purpose. I've built an stimulus controller that encapsulates the initialization of this plugin and some other custom implementations.

When the plugin is initialized, it adds some HTML markup with the "data-action" and stimulus tries to read it, throwing the parsing errors.

It would be helpful if we could tell stimulus to ignore parts of the controller element markup, avoiding the parsing errors. Not sure if that's possible, but I couldn't find anything like that.

Thanks again.

kmmbvnr commented 6 years ago

It looks there is possibility to instantiate a stimulus application class with custom schema for data-attr attribute naming

https://github.com/stimulusjs/stimulus/blob/master/packages/%40stimulus/core/src/schema.ts

beghelli commented 6 years ago

thanks @kmmbvnr

I think it makes much more sense to use a custom schema than to keep worrying about all third party libraries you might want to use. Good catch.