Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Babel 6 #59

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions addon/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import Ember from 'ember';
const { getOwner } = Ember;
import Mixin from '@ember/object/mixin';
import { get, computed } from '@ember/object';
import { inject } from '@ember/service';
import { next } from '@ember/runloop';
import { getOwner } from '@ember/application';

const {
computed,
get,
inject,
} = Ember;

export default Ember.Mixin.create({
export default Mixin.create({
scheduler: inject.service('scheduler'),
service: inject.service('router-scroll'),
service: inject('router-scroll'),

isFastBoot: computed(function() {
isFastBoot: computed(function () {
const fastboot = getOwner(this).lookup('service:fastboot');
return fastboot ? fastboot.get('isFastBoot') : false;
}),
Expand All @@ -24,7 +21,7 @@ export default Ember.Mixin.create({
didTransition(transitions, ...args) {
this._super(transitions, ...args);

if (get(this, 'isFastBoot')) { return; }
if (get(this, 'isFastBoot')) { return; }

this.get('scheduler').scheduleWork('afterContentPaint', () => {
this.updateScrollPosition(transitions);
Expand Down
9 changes: 2 additions & 7 deletions addon/locations/router-scroll.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
/* eslint-disable */
import Ember from 'ember';
import HistoryLocation from '@ember/routing/history-location';
import { set, get } from '@ember/object';

const uuid = () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : r & 3 | 8;
return v.toString(16);
});

const {
get,
set,
HistoryLocation,
} = Ember;

export default HistoryLocation.extend({
pushState(path) {
const state = { path, uuid: uuid() };
Expand Down
11 changes: 2 additions & 9 deletions addon/services/router-scroll.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
/* eslint-disable */
import Ember from 'ember';

const {
get,
set,
computed,
getWithDefault,
Service,
} = Ember;
import Service from '@ember/service';
import { getWithDefault, computed, set, get } from '@ember/object';

export default Service.extend({
init(...args) {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ember-router-scroll",
"version": "0.2.0",
"version": "0.3.0",
"description": "Scroll to top with preserved browser history scroll position",
"directories": {
"doc": "doc",
Expand Down Expand Up @@ -62,7 +62,7 @@
"ember-cli-app-version": "^3.0.0",
"ember-cli-dependency-checker": "^1.4.0",
"ember-cli-htmlbars": "^1.3.0",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-htmlbars-inline-precompile": "^0.4.4",
"ember-cli-inject-live-reload": "^1.4.0",
"ember-cli-jshint": "^2.0.1",
"ember-cli-qunit": "^3.1.2",
Expand All @@ -89,7 +89,7 @@
"browser scroll"
],
"dependencies": {
"ember-cli-babel": "^5.2.4",
"ember-cli-babel": "^6.6.0",
"ember-getowner-polyfill": "^1.2.3"
},
"ember-addon": {
Expand Down
5 changes: 2 additions & 3 deletions tests/dummy/app/app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import Application from '@ember/application';
import Ember from 'ember';
import Resolver from './resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';

let App;

Ember.MODEL_FACTORY_INJECTIONS = true;

App = Ember.Application.extend({
let App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/router.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ember from 'ember';
import EmberRouter from '@ember/routing/router';
import config from './config/environment';

const Router = Ember.Router.extend({
const Router = EmberRouter.extend({
location: config.locationType
});

Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/destroy-app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from 'ember';
import { run } from '@ember/runloop';

export default function destroyApp(application) {
Ember.run(application, 'destroy');
run(application, 'destroy');
}
4 changes: 1 addition & 3 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { Promise } from 'rsvp';
import { module } from 'qunit';
import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';

const { RSVP: { Promise } } = Ember;

export default function(name, options = {}) {
module(name, {
beforeEach() {
Expand Down
9 changes: 5 additions & 4 deletions tests/helpers/start-app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import Ember from 'ember';
import { run } from '@ember/runloop';
import { merge } from '@ember/polyfills';
import Application from '../../app';
import config from '../../config/environment';

export default function startApp(attrs) {
let application;

let attributes = Ember.merge({}, config.APP);
attributes = Ember.merge(attributes, attrs); // use defaults, but you can override;
let attributes = merge({}, config.APP);
attributes = merge(attributes, attrs); // use defaults, but you can override;

Ember.run(() => {
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
Expand Down
13 changes: 7 additions & 6 deletions tests/unit/mixins/router-scroll-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import { run, next } from '@ember/runloop';
import EmberObject from '@ember/object';
import RouterScroll from 'ember-router-scroll';
import { module, test } from 'qunit';

Expand All @@ -16,7 +17,7 @@ test('when the application is FastBooted', (assert) => {
assert.expect(1);

const done = assert.async();
const RouterScrollObject = Ember.Object.extend(RouterScroll);
const RouterScrollObject = EmberObject.extend(RouterScroll);
const subject = RouterScrollObject.create({
isFastBoot: true,
scheduler: getSchedulerMock(),
Expand All @@ -26,9 +27,9 @@ test('when the application is FastBooted', (assert) => {
},
});

Ember.run(() => {
run(() => {
subject.didTransition();
Ember.run.next(() => {
next(() => {
assert.ok(true, 'it should not call updateScrollPosition.');
done();
});
Expand All @@ -39,7 +40,7 @@ test('when the application is not FastBooted', (assert) => {
assert.expect(1);

const done = assert.async();
const RouterScrollObject = Ember.Object.extend(RouterScroll);
const RouterScrollObject = EmberObject.extend(RouterScroll);
const subject = RouterScrollObject.create({
isFastBoot: false,
scheduler: getSchedulerMock(),
Expand All @@ -49,7 +50,7 @@ test('when the application is not FastBooted', (assert) => {
},
});

Ember.run(() => {
run(() => {
subject.didTransition();
});
});
7 changes: 1 addition & 6 deletions tests/unit/services/router-scroll-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import Ember from 'ember';
import { set, get } from '@ember/object';
import { moduleFor, test } from 'ember-qunit';

const {
get,
set,
} = Ember;

moduleFor('service:router-scroll');

// Replace this with your real tests.
Expand Down
Loading