-
-
Notifications
You must be signed in to change notification settings - Fork 78.8k
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
Rewritten tooltip and popover without jquery #24014
Conversation
Did you update our event system because you had issue with it ? Because currently we are able to register for more than one event on the same element |
js/src/dom/eventHandler.js
Outdated
@@ -93,11 +93,13 @@ const eventRegistry = {} | |||
let uidEvent = 1 | |||
|
|||
function getUidEvent(element, uid) { | |||
return element.uidEvent = uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change not relevant here, please keep the affectation here
Before this, the same handler function cannot be registered and unregistered correctly for more than one element or event. That's why I removed the |
js/src/util.js
Outdated
@@ -77,6 +77,9 @@ const Util = (() => { | |||
}, | |||
|
|||
supportsTransitionEnd() { | |||
if (transition === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you changed that again 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh! This was an old branch, it seems that i've messed up this in a rebase..
js/src/tooltip.js
Outdated
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g') | ||
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g') | ||
|
||
function noop() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noop
should be added to our Util
object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
js/src/tooltip.js
Outdated
this.constructor.Event.CLICK, | ||
this.config.selector, | ||
this.config.selector || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.on
method explicitly checks for empty string, but selector can be undefined
or null
Probably the check event handler should be modified
js/src/tooltip.js
Outdated
) | ||
EventHandler.on(this.element, | ||
eventIn, | ||
this.config.selector || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here why ?
Can you make some tests on IE, on your computer ? because currently we cannot run our Saucelabs tests on folks PRs 😢 |
3400a49
to
e32b7ca
Compare
I've successfully executed the testsuite on chrome, chrome canary, firefox, safari, ie 11 and ms edge. Manual visual tests seem ok. |
js/src/util.js
Outdated
@@ -189,6 +189,10 @@ const Util = (() => { | |||
return false | |||
}, | |||
|
|||
noop() { | |||
return null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noop
should return an empty function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noop
should be an empty function, but ESLint does not allow empty functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disable that rule just for this line ;)
with // eslint-disable-next-line no-empty-function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
js/tests/unit/dom/eventHandler.js
Outdated
|
||
var element = document.createElement('div') | ||
var handler = function () { | ||
assert.ok(true, 'listener called') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use notOk
here because it's a failed case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
e32b7ca
to
f7b6b83
Compare
@@ -614,10 +621,15 @@ const Tooltip = (() => { | |||
} | |||
|
|||
_getConfig(config) { | |||
config = $.extend( | |||
if (typeof config !== 'undefined' && | |||
typeof config.container === 'object' && config.container.jquery) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is it config.container.jquery
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checks if config.container
is a jquery object. In that case i'll get the dom element via [0]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's right, I forgot about that property 😄
Tooltip and popover rewritten without jquery
The event system has been modified to allow registering the same handler for more than one event, delegate events in
.one
method and unregistering one-off handlers through.off
The
delegateTarget
property has been added to the event object, replacing the jquerycurrentTarget
(native events' currentTarget property is read-only)