Rewritten modal without jquery#23955
Conversation
There was a problem hiding this comment.
Why did you add a new regex here ? off method already work
There was a problem hiding this comment.
The off implementation was not complete and i think i've messed up some things. Now working on a cleaner and more jQuery-like solution.
There was a problem hiding this comment.
here you check for jQuery !== undefined it should be better with $ which come from your Util.jQuery getter
There was a problem hiding this comment.
You're right. Fixed.
There was a problem hiding this comment.
why do you call stopImmediatePropagation here ? evt isn't dispatched
There was a problem hiding this comment.
setDataAttribute and removeDataAttribute should be in our DOM Manipulator here : https://github.com/twbs/bootstrap/blob/v4-without-jquery/js/src/dom/manipulator.js
There was a problem hiding this comment.
Without a change here, our Modal continue to depend on jQuery
There was a problem hiding this comment.
I've missed it. I've just changed it.
|
You made a very good work here @alekitto but they are few changes here before I can merge your PR 👍 |
There was a problem hiding this comment.
Not a big fan here because EventHandler.getBrowserTransitionEnd() will be called each time Util.supportsTransitionEnd() is called
9d8fa89 to
6717d36
Compare
|
I updated the base branch with |
f6d0038 to
f1e343c
Compare
|
Ok, i've rebased my branch with upstream. Now working on your comments.. |
f1e343c to
f5a9958
Compare
There was a problem hiding this comment.
Here you add a check if transition is set or not, you should revert this change it was better before that, because they aren't any check done each time we call this method
There was a problem hiding this comment.
Cyclic import (util -> eventHandler -> util) was causing me troubles yesterday, but now seems working correctly. Probably it was another error.
There was a problem hiding this comment.
if you want you can use EventHandler here
f5a9958 to
a9e825d
Compare
|
Oups last thing I forgot, can you update our visual modal test ? please |
a9e2521 to
6c5846d
Compare
|
Ok, EventHandler off method has been rewritten to support namespaced events ( Visual modal test has been updated |
|
I don't understand why you made that change on EDIT : |
There was a problem hiding this comment.
that's not our button plugin 😄
|
The |
|
Ok thank you for the explanation 👍 and yep the second point wasn't implemented thank you |
|
Yes, now |
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
|
About Modal events, can i suggest a feature request ? How about adding a public method to listen a modal event: class Modal {
//...
on(event, callback) {
this._element.addEventListener(`${event}${EVENT_KEY}`, callback);
}
//...
}So instead of: let myModal = new bootstrap.Modal(document.getElementById('myModal'));
myModal._element.addEventListener('hidden.bs.modal', function (e) {
// do something...
})We can do something like this: var myModal = new bootstrap.Modal(document.getElementById('myModal'));
myModal.on('hidden', function (e) {
// do something...
});I don't know if it's going to have a conflict with jquery but we can change the method name I can create a PR for this feature if it's OK 👍 |
|
My 2 cents: This could be an interesting feature, but I think that should be implemented for all the components. const myCollapse = new bootstrap.Collapse(document.getElementById('test-collapse'));
myCollapse.on('shown', e => { ... });could be equally good and useful. @arcanedev-maroc probably you should open a new issue proposing a these changes to the event system of the components to better discuss pros and cons of this new design. |
* Trigger jquery events if available in event handler * Rewritten modal without jquery
* Trigger jquery events if available in event handler * Rewritten modal without jquery
To make it work correctly the following changes were required:
Util.extendnow supports multiple objects