mirror of https://github.com/twbs/bootstrap.git
				
				
				
			Cache a few variables.
This commit is contained in:
		
							parent
							
								
									c86b74fe88
								
							
						
					
					
						commit
						b31046aab3
					
				|  | @ -111,11 +111,12 @@ class Button { | ||||||
| 
 | 
 | ||||||
|   static _jQueryInterface(config) { |   static _jQueryInterface(config) { | ||||||
|     return this.each(function () { |     return this.each(function () { | ||||||
|       let data = $(this).data(DATA_KEY) |       const $element = $(this) | ||||||
|  |       let data = $element.data(DATA_KEY) | ||||||
| 
 | 
 | ||||||
|       if (!data) { |       if (!data) { | ||||||
|         data = new Button(this) |         data = new Button(this) | ||||||
|         $(this).data(DATA_KEY, data) |         $element.data(DATA_KEY, data) | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if (config === 'toggle') { |       if (config === 'toggle') { | ||||||
|  |  | ||||||
|  | @ -129,10 +129,11 @@ class Carousel { | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   nextWhenVisible() { |   nextWhenVisible() { | ||||||
|  |     const $element = $(this._element) | ||||||
|     // Don't call next when the page isn't visible
 |     // Don't call next when the page isn't visible
 | ||||||
|     // or the carousel or its parent isn't visible
 |     // or the carousel or its parent isn't visible
 | ||||||
|     if (!document.hidden && |     if (!document.hidden && | ||||||
|       ($(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden')) { |       ($element.is(':visible') && $element.css('visibility') !== 'hidden')) { | ||||||
|       this.next() |       this.next() | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | @ -324,11 +324,11 @@ class Collapse { | ||||||
| 
 | 
 | ||||||
|   static _jQueryInterface(config) { |   static _jQueryInterface(config) { | ||||||
|     return this.each(function () { |     return this.each(function () { | ||||||
|       const $this = $(this) |       const $element = $(this) | ||||||
|       let data = $this.data(DATA_KEY) |       let data = $element.data(DATA_KEY) | ||||||
|       const _config = { |       const _config = { | ||||||
|         ...Default, |         ...Default, | ||||||
|         ...$this.data(), |         ...$element.data(), | ||||||
|         ...typeof config === 'object' && config ? config : {} |         ...typeof config === 'object' && config ? config : {} | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|  | @ -338,7 +338,7 @@ class Collapse { | ||||||
| 
 | 
 | ||||||
|       if (!data) { |       if (!data) { | ||||||
|         data = new Collapse(this, _config) |         data = new Collapse(this, _config) | ||||||
|         $this.data(DATA_KEY, data) |         $element.data(DATA_KEY, data) | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if (typeof config === 'string') { |       if (typeof config === 'string') { | ||||||
|  |  | ||||||
|  | @ -735,7 +735,8 @@ class Tooltip { | ||||||
| 
 | 
 | ||||||
|   static _jQueryInterface(config) { |   static _jQueryInterface(config) { | ||||||
|     return this.each(function () { |     return this.each(function () { | ||||||
|       let data = $(this).data(DATA_KEY) |       const $element = $(this) | ||||||
|  |       let data = $element.data(DATA_KEY) | ||||||
|       const _config = typeof config === 'object' && config |       const _config = typeof config === 'object' && config | ||||||
| 
 | 
 | ||||||
|       if (!data && /dispose|hide/.test(config)) { |       if (!data && /dispose|hide/.test(config)) { | ||||||
|  | @ -744,7 +745,7 @@ class Tooltip { | ||||||
| 
 | 
 | ||||||
|       if (!data) { |       if (!data) { | ||||||
|         data = new Tooltip(this, _config) |         data = new Tooltip(this, _config) | ||||||
|         $(this).data(DATA_KEY, data) |         $element.data(DATA_KEY, data) | ||||||
|       } |       } | ||||||
| 
 | 
 | ||||||
|       if (typeof config === 'string') { |       if (typeof config === 'string') { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue