From ae5027c0d98c5c308c92acf9a2f5831cd573a1d4 Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Thu, 11 Feb 2016 12:17:35 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=20fix=20sorting=20test,=20use=20?= =?UTF-8?q?=5FgetOption?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/isotope.js | 18 ++++-------------- test/sorting.js | 22 +++++++++------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/js/isotope.js b/js/isotope.js index 64b4d65..210187e 100644 --- a/js/isotope.js +++ b/js/isotope.js @@ -76,16 +76,6 @@ var trim = String.prototype.trim ? return str.replace( /^\s+|\s+$/g, '' ); }; -var docElem = document.documentElement; - -var getText = docElem.textContent ? - function( elem ) { - return elem.textContent; - } : - function( elem ) { - return elem.innerText; - }; - // -------------------------- isotopeDefinition -------------------------- // // create an Outlayer layout class @@ -153,7 +143,7 @@ var getText = docElem.textContent ? Isotope.prototype.layout = function() { // if first time doing layout, do all magic - if ( !this._isLayoutInited && this.options.isInitLayout ) { + if ( !this._isLayoutInited && this._getOption('initLayout') ) { this.arrange(); return; } @@ -208,8 +198,8 @@ var getText = docElem.textContent ? // Don't animate/transition first layout // Or don't animate/transition other layouts Isotope.prototype._getIsInstant = function() { - var isInstant = this.options.isLayoutInstant !== undefined ? - this.options.isLayoutInstant : !this._isLayoutInited; + var isInstant = this._getOption('initLayout') !== undefined ? + this._getOption('layoutInstant') : !this._isLayoutInited; this._isInstant = isInstant; return isInstant; }; @@ -390,7 +380,7 @@ var getText = docElem.textContent ? // otherwise, assume its a querySelector, and get its text getValue = function( elem ) { var child = elem.querySelector( query ); - return child && getText( child ); + return child && child.textContent; }; } return getValue; diff --git a/test/sorting.js b/test/sorting.js index d4d1a18..0bc4246 100644 --- a/test/sorting.js +++ b/test/sorting.js @@ -1,16 +1,7 @@ -( function() { - -'use strict'; - -function getItemsText( iso ) { - var texts = iso.filteredItems.map( function( item ) { - return item.element.textContent; - }) - return texts.join(','); -} - test( 'sorting', function() { + 'use strict'; + // sorting with history ( function() { var iso = new Isotope( '#sorting1', { @@ -62,6 +53,11 @@ test( 'sorting', function() { iso.destroy(); })(); -}); + function getItemsText( iso ) { + var texts = iso.filteredItems.map( function( item ) { + return item.element.textContent; + }); + return texts.join(','); + } -})(); +});