Skip to content

Commit

Permalink
Merge pull request #220 from FabHof/master
Browse files Browse the repository at this point in the history
Remove jQuery from interactor and components
  • Loading branch information
efx authored Jun 28, 2019
2 parents f371ee2 + dc7b101 commit 2085793
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
38 changes: 17 additions & 21 deletions addon-test-support/interactor.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { triggerEvent } from '@ember/test-helpers';
import $ from 'jquery';

const MONTH_SELECTOR = '.pika-lendar:visible .pika-select-month';
const YEAR_SELECTOR = '.pika-lendar:visible .pika-select-year';
const MONTH_SELECTOR = '.pika-lendar .pika-select-month';
const YEAR_SELECTOR = '.pika-lendar .pika-select-year';

/**
* @param {Date} date
Expand All @@ -13,42 +12,39 @@ export async function selectDate(date) {
const year = date.getFullYear();
const selectEvent = 'ontouchend' in document ? 'touchend' : 'mousedown';

$(YEAR_SELECTOR).val(year);
await triggerEvent($(YEAR_SELECTOR)[0], 'change');
const yearElement = document.querySelector(YEAR_SELECTOR);
yearElement.value = year;
await triggerEvent(yearElement, 'change');

$(MONTH_SELECTOR).val(month);
await triggerEvent($(MONTH_SELECTOR)[0], 'change');
const monthElement = document.querySelector(MONTH_SELECTOR);
monthElement.value = month;
await triggerEvent(monthElement, 'change');

await triggerEvent(
$(
'td[data-day="' + day + '"]:not(.is-outside-current-month) button:visible'
)[0],
document.querySelector(
'td[data-day="' + day + '"]:not(.is-outside-current-month) button'
),
selectEvent
);
}

export function selectedDay() {
return $('.pika-single td.is-selected button').html();
return document.querySelector('.pika-single td.is-selected button').innerHTML;
}

export function selectedMonth() {
return $(MONTH_SELECTOR + ' option:selected').val();
return document.querySelector(MONTH_SELECTOR).value;
}

export function selectedYear() {
return $(YEAR_SELECTOR + ' option:selected').val();
return document.querySelector(YEAR_SELECTOR).value;
}

export function minimumYear() {
return $(YEAR_SELECTOR)
.children()
.first()
.val();
return document.querySelector(YEAR_SELECTOR).options[0].value;
}

export function maximumYear() {
return $(YEAR_SELECTOR)
.children()
.last()
.val();
const options = document.querySelector(YEAR_SELECTOR).options;
return options[options.length - 1].value;
}
5 changes: 4 additions & 1 deletion addon/components/pikaday-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export default Component.extend(PikadayMixin, {
},

onPikadayClose() {
if (this.get('pikaday').getDate() === null || isEmpty(this.$().val())) {
if (
this.get('pikaday').getDate() === null ||
isEmpty(this.get('element').value)
) {
this.set('value', null);
this.get('onSelection')(null);
}
Expand Down
7 changes: 5 additions & 2 deletions addon/components/pikaday-inputless.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ export default Component.extend(PikadayMixin, {
layout,

didInsertElement() {
this.set('field', this.$('.ember-pikaday-input')[0]);
this.set('pikadayContainer', this.$('.ember-pikaday-container')[0]);
this.set('field', this.element.querySelector('.ember-pikaday-input'));
this.set(
'pikadayContainer',
this.element.querySelector('.ember-pikaday-container')
);
this.setupPikaday();
},

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"test": "tests"
},
"devDependencies": {
"@ember/jquery": "^0.5.2",
"@ember/optional-features": "^0.6.3",
"@ember/test-helpers": "^0.7.25",
"broccoli-asset-rev": "^2.7.0",
Expand Down
9 changes: 0 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
# yarn lockfile v1


"@ember/jquery@^0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@ember/jquery/-/jquery-0.5.2.tgz#fe312c03ada0022fa092d23f7cd7e2eb0374b53a"
dependencies:
broccoli-funnel "^2.0.1"
ember-cli-babel "^6.6.0"
jquery "^3.3.1"
resolve "^1.7.1"

"@ember/optional-features@^0.6.3":
version "0.6.4"
resolved "https://registry.yarnpkg.com/@ember/optional-features/-/optional-features-0.6.4.tgz#8199f853c1781234fcb1f05090cddd0b822bff69"
Expand Down

0 comments on commit 2085793

Please sign in to comment.