]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Use pull request #11368 from DanielRuf/style/use-typeof-for-checking-undefined-11363...
authorDaniel Ruf <daniel@daniel-ruf.de>
Fri, 6 Jul 2018 20:31:47 +0000 (22:31 +0200)
committerNicolas Coden <nicolas@ncoden.fr>
Fri, 6 Jul 2018 20:51:40 +0000 (22:51 +0200)
dd493bd64 style: use typeof for checking undefined

Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
js/foundation.core.js
js/foundation.dropdownMenu.js
js/foundation.equalizer.js
js/foundation.magellan.js
js/foundation.util.imageLoader.js
js/foundation.util.mediaQuery.js

index 8d88c89900e05a42da3b167d74ddba47a0e712ae..ec9cd6da0a8ab091a8e0a99dda3cb75e94335011 100644 (file)
@@ -201,7 +201,7 @@ var Foundation = {
         var args = Array.prototype.slice.call(arguments, 1);//collect all the arguments, if necessary
         var plugClass = this.data('zfPlugin');//determine the class of plugin
 
-        if(plugClass !== undefined && plugClass[method] !== undefined){//make sure both the class and method exist
+        if(typeof plugClass !== 'undefined' && typeof plugClass[method] !== 'undefined'){//make sure both the class and method exist
           if(this.length === 1){//if there's only one, call it directly.
               plugClass[method].apply(plugClass, args);
           }else{
@@ -310,12 +310,12 @@ if (!Function.prototype.bind) {
 }
 // Polyfill to get the name of a function in IE9
 function functionName(fn) {
-  if (Function.prototype.name === undefined) {
+  if (typeof Function.prototype.name === 'undefined') {
     var funcNameRegex = /function\s([^(]{1,})\(/;
     var results = (funcNameRegex).exec((fn).toString());
     return (results && results.length > 1) ? results[1].trim() : "";
   }
-  else if (fn.prototype === undefined) {
+  else if (typeof fn.prototype === 'undefined') {
     return fn.constructor.name;
   }
   else {
index 1cfd7a6d81f21f1163fa90df6b554e4723d77b4d..2d9bb2cf046090069d06550357da10750b4ceb39 100644 (file)
@@ -326,7 +326,7 @@ class DropdownMenu extends Plugin {
     var $toClose;
     if ($elem && $elem.length) {
       $toClose = $elem;
-    } else if (idx !== undefined) {
+    } else if (typeof idx !== 'undefined') {
       $toClose = this.$tabs.not(function(i, el) {
         return i === idx;
       });
index f87714af0752da8ebd5c08588e00717f36573e67..13335546747b1e5df7fae9cb6e50b337b7432ad4 100644 (file)
@@ -60,7 +60,7 @@ class Equalizer extends Plugin {
     }else{
       this._events();
     }
-    if((tooSmall !== undefined && tooSmall === false) || tooSmall === undefined){
+    if((typeof tooSmall !== 'undefined' && tooSmall === false) || typeof tooSmall === 'undefined'){
       if(imgs.length){
         onImagesLoaded(imgs, this._reflow.bind(this));
       }else{
index 3566b64e8c8fc6d858301ca807a2b556d7bbe35d..42570d3dde850e417e8ad5ab2c61d1cc0cde8074 100644 (file)
@@ -175,7 +175,7 @@ class Magellan extends Plugin {
     // Get the new active link
     const $oldActive = this.$active;
     let activeHash = '';
-    if(activeIdx !== undefined){
+    if(typeof activeIdx !== 'undefined'){
       this.$active = this.$links.filter('[href="#' + this.$targets.eq(activeIdx).data('magellan-target') + '"]');
       if (this.$active.length) activeHash = this.$active[0].getAttribute('href');
     }else{
index 9fe1d215f99ba262757478e6913733780faf5fa8..46918470186feb75d497eb2e51cdb8e1863d6055 100644 (file)
@@ -17,7 +17,7 @@ function onImagesLoaded(images, callback){
 
   images.each(function(){
     // Check if image is loaded
-    if (this.complete && this.naturalWidth !== undefined) {
+    if (this.complete && typeof this.naturalWidth !== 'undefined') {
       singleImageLoaded();
     }
     else {
index e60c437897c5ae241c1c654ba21e42f1a9abb931..e80f973ce5ca6b62de48b9249d795cc6fc93c5fc 100644 (file)
@@ -216,7 +216,7 @@ function parseStyleToObject(str) {
 
     // missing `=` should be `null`:
     // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
-    val = val === undefined ? null : decodeURIComponent(val);
+    val = typeof val === 'undefined' ? null : decodeURIComponent(val);
 
     if (!ret.hasOwnProperty(key)) {
       ret[key] = val;