fengyuanchen / cropperjs

JavaScript image cropper.
https://fengyuanchen.github.io/cropperjs/
MIT License
12.86k stars 2.39k forks source link

Compatibility issue with StimulusJS #319

Closed meneerprins closed 6 years ago

meneerprins commented 6 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report 
[ X ] Feature request
[ ] Documentation issue or request

Current behavior

CropperJS adds [data-action] attributes when initialised and StimulusJS uses [data-action] to add behaviours which results in issues when using both libraries.

Suggested behaviour

Add an option to change the name of the data attributes, add a namespace or change the default name (like [data-cropperjs-action]).

Minimal reproduction of the problem with instructions

Use StimulusJS and CropperJS at the same time.

What is the motivation / use case for changing the behavior?

CropperJS is the only crop library that has everything I need and StimulusJS is new but already has many people that want to use it and I found this problem when redoing a whole app with StimulusJS.

Environment


Cropper.js version: 1.3.2            
stephendolan commented 6 years ago

@meneerprins,

As a workaround that you can use from the StimulusJS side, see this issue: https://github.com/stimulusjs/stimulus/issues/124

I modified my StimulusJS application schema to use data-saction instead of data-action, so that when CropperJS gets around to adding the same customization feature it will be easier to search and replace.

meneerprins commented 6 years ago

That is indeed an option but I would still prefer to change the Cropperjs data tag since it's generated & the Stimulus data-action is used in tons of places in a large application. Is there really no other possibility?

mcrumm commented 6 years ago

I, too, would love to see out-of-the-box compatibility, here. Specifically, applying the cropper namespace to the data keys in the same way it's currently applied to the class keys would be a simple path to such compatibility.

@fengyuanchen would you consider a PR to this effect? I'd be happy to put one together.