aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2017-09-26 17:46:16 +0300
committerGitHub <[email protected]>2017-09-26 17:46:16 +0300
commitc090c79a709a84cb6e2bd5dbed6343ae49c861a1 (patch)
treecadb5d1e7a94588047081bb8d8c4f92914aaf043 /js/src
parent8e56145e45e9d58e23c5f339b6cac50e751e36a7 (diff)
parent3eae92f1fec3c84acf38bd7e16a14eac48868334 (diff)
downloadbootstrap-c090c79a709a84cb6e2bd5dbed6343ae49c861a1.tar.xz
bootstrap-c090c79a709a84cb6e2bd5dbed6343ae49c861a1.zip
Merge branch 'v4-dev' into btn-active
Diffstat (limited to 'js/src')
-rw-r--r--js/src/collapse.js17
-rw-r--r--js/src/scrollspy.js3
-rw-r--r--js/src/tab.js8
-rw-r--r--js/src/tooltip.js6
-rw-r--r--js/src/util.js10
5 files changed, 31 insertions, 13 deletions
diff --git a/js/src/collapse.js b/js/src/collapse.js
index acc959d40..fa082f133 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -33,7 +33,7 @@ const Collapse = (() => {
const DefaultType = {
toggle : 'boolean',
- parent : 'string'
+ parent : '(string|element)'
}
const Event = {
@@ -289,7 +289,18 @@ const Collapse = (() => {
}
_getParent() {
- const parent = $(this._config.parent)[0]
+ let parent = null
+ if (Util.isElement(this._config.parent)) {
+ parent = this._config.parent
+
+ // it's a jQuery object
+ if (typeof this._config.parent.jquery !== 'undefined') {
+ parent = this._config.parent[0]
+ }
+ } else {
+ parent = $(this._config.parent)[0]
+ }
+
const selector =
`[data-toggle="collapse"][data-parent="${this._config.parent}"]`
@@ -363,7 +374,7 @@ const Collapse = (() => {
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element
- if (event.target.tagName === 'A' && !$.contains(this, event.target)) {
+ if (event.currentTarget.tagName === 'A') {
event.preventDefault()
}
diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js
index 70067c0b3..e8f0d3101 100644
--- a/js/src/scrollspy.js
+++ b/js/src/scrollspy.js
@@ -54,6 +54,7 @@ const ScrollSpy = (() => {
ACTIVE : '.active',
NAV_LIST_GROUP : '.nav, .list-group',
NAV_LINKS : '.nav-link',
+ NAV_ITEMS : '.nav-item',
LIST_ITEMS : '.list-group-item',
DROPDOWN : '.dropdown',
DROPDOWN_ITEMS : '.dropdown-item',
@@ -264,6 +265,8 @@ const ScrollSpy = (() => {
// Set triggered links parents as active
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
$link.parents(Selector.NAV_LIST_GROUP).prev(`${Selector.NAV_LINKS}, ${Selector.LIST_ITEMS}`).addClass(ClassName.ACTIVE)
+ // Handle special case when .nav-link is inside .nav-item
+ $link.parents(Selector.NAV_LIST_GROUP).prev(Selector.NAV_ITEMS).children(Selector.NAV_LINKS).addClass(ClassName.ACTIVE)
}
$(this._scrollElement).trigger(Event.ACTIVATE, {
diff --git a/js/src/tab.js b/js/src/tab.js
index 18af4e7e2..2a554c287 100644
--- a/js/src/tab.js
+++ b/js/src/tab.js
@@ -196,11 +196,15 @@ const Tab = (() => {
$(dropdownChild).removeClass(ClassName.ACTIVE)
}
- active.setAttribute('aria-expanded', false)
+ if (active.getAttribute('role') === 'tab') {
+ active.setAttribute('aria-selected', false)
+ }
}
$(element).addClass(ClassName.ACTIVE)
- element.setAttribute('aria-expanded', true)
+ if (element.getAttribute('role') === 'tab') {
+ element.setAttribute('aria-selected', true)
+ }
if (isTransitioning) {
Util.reflow(element)
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index 5dc28ab7e..ca7e52b14 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -622,18 +622,18 @@ const Tooltip = (() => {
config
)
- if (config.delay && typeof config.delay === 'number') {
+ if (typeof config.delay === 'number') {
config.delay = {
show : config.delay,
hide : config.delay
}
}
- if (config.title && typeof config.title === 'number') {
+ if (typeof config.title === 'number') {
config.title = config.title.toString()
}
- if (config.content && typeof config.content === 'number') {
+ if (typeof config.content === 'number') {
config.content = config.content.toString()
}
diff --git a/js/src/util.js b/js/src/util.js
index b18d0f776..7eb25de55 100644
--- a/js/src/util.js
+++ b/js/src/util.js
@@ -32,10 +32,6 @@ const Util = (() => {
return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
}
- function isElement(obj) {
- return (obj[0] || obj).nodeType
- }
-
function getSpecialTransitionEndEvent() {
return {
bindType: transition.end,
@@ -138,12 +134,16 @@ const Util = (() => {
return Boolean(transition)
},
+ isElement(obj) {
+ return (obj[0] || obj).nodeType
+ },
+
typeCheckConfig(componentName, config, configTypes) {
for (const property in configTypes) {
if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
const expectedTypes = configTypes[property]
const value = config[property]
- const valueType = value && isElement(value) ?
+ const valueType = value && Util.isElement(value) ?
'element' : toType(value)
if (!new RegExp(expectedTypes).test(valueType)) {