Skip to content

Commit

Permalink
Merge pull request #105 from Yoast/stories/select2-compatibility
Browse files Browse the repository at this point in the history
Determine select2 version from ACF instead of guessing from ACF version
  • Loading branch information
moorscode authored Oct 30, 2017
2 parents 419a01a + 182ca63 commit 6019262
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/src/scraper/scraper.taxonomy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Scraper.prototype.scrape = function(fields){

if( field.$el.find('.acf-taxonomy-field[data-type="multi_select"]').length > 0 ){

var select2Target = (helper.acf_version >= 5.6)?'select':'input';
var select2Target = (acf.select2.version >= 4)?'select':'input';

terms = _.pluck(
field.$el.find('.acf-taxonomy-field[data-type="multi_select"] ' + select2Target )
Expand Down
2 changes: 1 addition & 1 deletion js/yoast-acf-analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ Scraper.prototype.scrape = function(fields){

if( field.$el.find('.acf-taxonomy-field[data-type="multi_select"]').length > 0 ){

var select2Target = (helper.acf_version >= 5.6)?'select':'input';
var select2Target = (acf.select2.version >= 4)?'select':'input';

terms = _.pluck(
field.$el.find('.acf-taxonomy-field[data-type="multi_select"] ' + select2Target )
Expand Down
8 changes: 4 additions & 4 deletions tests/js/system/tests/acf5/relational.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ module.exports = {

browser.execute(
function() {
return parseFloat(YoastACFAnalysisConfig.acfVersion, 10);
return parseFloat(acf.select2.version, 10);
},
[],
function( result ){
var acfVersion = result.value;
var select2Version = result.value;
var inputSelector, optionSelector, choiceSelector;

if( acfVersion >= 5.6 ){
if( select2Version >= 4 ){
inputSelector = '.acf-taxonomy-field[data-type="multi_select"][data-taxonomy="category"] .select2-search__field ';
optionSelector = '.select2-results__option--highlighted';
choiceSelector = '.acf-taxonomy-field .select2-selection__choice';
Expand All @@ -64,7 +64,7 @@ module.exports = {
browser.execute(
function() {

var select2Target = (parseFloat(YoastACFAnalysisConfig.acfVersion, 10) >= 5.6)?'select':'input';
var select2Target = (parseFloat(acf.select2.version, 10) >= 4)?'select':'input';

return jQuery('.acf-taxonomy-field[data-type="multi_select"] ' + select2Target).select2('data')[0].text
},
Expand Down

0 comments on commit 6019262

Please sign in to comment.