]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Cache a few variables.
authorXhmikosR <xhmikosr@gmail.com>
Wed, 8 Jul 2020 17:09:39 +0000 (20:09 +0300)
committerXhmikosR <xhmikosr@gmail.com>
Mon, 21 Sep 2020 11:58:34 +0000 (14:58 +0300)
js/src/button.js
js/src/carousel.js
js/src/collapse.js
js/src/tooltip.js

index b244c8df479c82f491335b0867a1f7e94e284e5b..d793785829fc452e1d60e91f81334ccc194a43b5 100644 (file)
@@ -111,11 +111,12 @@ class Button {
 
   static _jQueryInterface(config) {
     return this.each(function () {
-      let data = $(this).data(DATA_KEY)
+      const $element = $(this)
+      let data = $element.data(DATA_KEY)
 
       if (!data) {
         data = new Button(this)
-        $(this).data(DATA_KEY, data)
+        $element.data(DATA_KEY, data)
       }
 
       if (config === 'toggle') {
index 8c03818ab0ea24c6cc13776fd3f6ee0c2ddb7562..62b4ce1e4dd1b668307edd53f97de3b34907e3be 100644 (file)
@@ -129,10 +129,11 @@ class Carousel {
   }
 
   nextWhenVisible() {
+    const $element = $(this._element)
     // Don't call next when the page isn't visible
     // or the carousel or its parent isn't visible
     if (!document.hidden &&
-      ($(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden')) {
+      ($element.is(':visible') && $element.css('visibility') !== 'hidden')) {
       this.next()
     }
   }
index 04653b835eb9586691595c1ec0512e586365e6c3..605299515370ac9c060de12c5db674fee18a6487 100644 (file)
@@ -324,11 +324,11 @@ class Collapse {
 
   static _jQueryInterface(config) {
     return this.each(function () {
-      const $this = $(this)
-      let data = $this.data(DATA_KEY)
+      const $element = $(this)
+      let data = $element.data(DATA_KEY)
       const _config = {
         ...Default,
-        ...$this.data(),
+        ...$element.data(),
         ...typeof config === 'object' && config ? config : {}
       }
 
@@ -338,7 +338,7 @@ class Collapse {
 
       if (!data) {
         data = new Collapse(this, _config)
-        $this.data(DATA_KEY, data)
+        $element.data(DATA_KEY, data)
       }
 
       if (typeof config === 'string') {
index a1ce7ca87ecc4f7c716e4bc8a00230f58a227634..e2a554014d5e733e66b3560f05253e349d724a96 100644 (file)
@@ -735,7 +735,8 @@ class Tooltip {
 
   static _jQueryInterface(config) {
     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
 
       if (!data && /dispose|hide/.test(config)) {
@@ -744,7 +745,7 @@ class Tooltip {
 
       if (!data) {
         data = new Tooltip(this, _config)
-        $(this).data(DATA_KEY, data)
+        $element.data(DATA_KEY, data)
       }
 
       if (typeof config === 'string') {