easy-markdown-editor icon indicating copy to clipboard operation
easy-markdown-editor copied to clipboard

Avoid data attribute namespace conflicts

Open vanillajonathan opened this issue 3 years ago • 6 comments

vanillajonathan avatar May 18 '22 22:05 vanillajonathan

What problem does this solve?

Also would be a breaking change.

Ionaru avatar May 19 '22 07:05 Ionaru

The problem it solves is it avoids any potential conflicts when using other libraries and code that might also use data attributes by putting all EasyMDE-related data attributes in its own namespace.

This is also done by Bootstrap.

Data attributes for all JavaScript plugins are now namespaced to help distinguish Bootstrap functionality from third parties and your own code. For example, we use data-bs-toggle instead of data-toggle.

https://getbootstrap.com/docs/5.2/migration/#javascript

It is not a breaking change since the data-img-src (now data-mde-img-src) attribute is not part of the public API, it is not mentioned anywhere in the documentation, it is an internal concern only.

vanillajonathan avatar May 19 '22 08:05 vanillajonathan

Even though it is not documented, it is still part of the public API and can be used for styling purposes (see here: https://github.com/Ionaru/easy-markdown-editor/blob/master/src/css/easymde.css#L368).

There's a reasonable chance other developers have used that attribute to hook in extra functionality or style an element in the 2 years data-img-src has existed.

Ionaru avatar May 19 '22 13:05 Ionaru

I see. I was not aware it was considered part of the public API. The data attribute is not mentioned in the documentation.

If you don't want to merge it, consider assigning the PR to a Project or a Label for the upcoming major rewrite.

vanillajonathan avatar May 19 '22 13:05 vanillajonathan

Ref #447

Ionaru avatar May 19 '22 14:05 Ionaru

Yeah, I saw that post. Good that you made a ref to it. GitHub includes "Projects" and "Labels" too which can be assigned to issues and pull requests.

vanillajonathan avatar May 19 '22 14:05 vanillajonathan