Skip to content

Commit d6b0e0c

Browse files
committed
⚰️ Fixing Deprecations
1 parent 18b961c commit d6b0e0c

File tree

8 files changed

+85
-39
lines changed

8 files changed

+85
-39
lines changed

MODULE_REPORT.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Module Report
2+
### Unknown Global
3+
4+
**Global**: `Ember.Logger`
5+
6+
**Location**: `addon/services/showdown-converter.js` at line 16
7+
8+
```js
9+
// set showdown global settings from the environment
10+
if (Ember.isEmpty(config.APP.showdown)) {
11+
Ember.Logger.info('The `ember-cli-marked-down` addon will use ShowdownJS defaults to create the Converters.');
12+
Ember.Logger.info('If you want to customize ShowdownJS behaviour, please see the ember-cli-marked-down README: https://github.com/cybertoothca/ember-cli-marked-down#showdownjs-configuration-optional');
13+
return;
14+
```
15+
16+
### Unknown Global
17+
18+
**Global**: `Ember.Logger`
19+
20+
**Location**: `addon/services/showdown-converter.js` at line 17
21+
22+
```js
23+
if (Ember.isEmpty(config.APP.showdown)) {
24+
Ember.Logger.info('The `ember-cli-marked-down` addon will use ShowdownJS defaults to create the Converters.');
25+
Ember.Logger.info('If you want to customize ShowdownJS behaviour, please see the ember-cli-marked-down README: https://github.com/cybertoothca/ember-cli-marked-down#showdownjs-configuration-optional');
26+
return;
27+
}
28+
```
Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,57 @@
1-
import Ember from 'ember';
2-
import startsWith from 'lodash.startswith';
3-
import layout from '../templates/components/set-links-target';
1+
import $ from "jquery";
2+
import startsWith from "lodash.startswith";
43

5-
export default Ember.Component.extend({
6-
classNames: ['set-links-target'],
4+
import Component from "@ember/component";
5+
import { computed } from "@ember/object";
6+
import { isEmpty, isPresent } from "@ember/utils";
7+
8+
import layout from "../templates/components/set-links-target";
9+
10+
export default Component.extend({
11+
classNames: ["set-links-target"],
712
/**
813
* When true (DEFAULT), any links found in the yield with the same host as `document.location.origin` will not have their
914
* `target` attribute modified.
1015
* When false, every link that is found without a target will be modified.
1116
*/
12-
'excludeSelfLinks?': true,
17+
"excludeSelfLinks?": true,
1318
layout,
1419
/**
1520
* Can be one of `_blank`, `_self`, `_parent`, `_top`, or a frame name.
1621
* @see http://www.w3schools.com/jsref/prop_anchor_target.asp
1722
*/
18-
targetValue: '_blank',
23+
targetValue: "_blank",
1924
/**
2025
* Determines the `window.document.location.origin` because PhantomJS does not have a notion of the location object.
2126
*/
22-
_origin: Ember.computed(function() {
23-
if (Ember.isPresent(document)) {
27+
_origin: computed(function () {
28+
if (isPresent(document)) {
2429
return document.location.origin;
2530
}
26-
return 'http://localhost:7357';
31+
return "http://localhost:7357";
2732
}),
2833
/**
2934
* Sets any `<a>` (link) `target` attributes to whatever we've specified in the `targetValue` property.
3035
*/
31-
_setTarget: Ember.on('didInsertElement', function() {
32-
const excludeSelfLinks = this.get('excludeSelfLinks?');
33-
const origin = this.get('_origin');
34-
const targetValue = this.get('targetValue');
36+
didInsertElement() {
37+
const excludeSelfLinks = this.get("excludeSelfLinks?");
38+
const origin = this.get("_origin");
39+
const targetValue = this.get("targetValue");
3540
// for each anchor check if we should set the target
36-
this.$('a').each((index, element) => {
37-
const link = Ember.$(element);
41+
this.$("a").each((index, element) => {
42+
const link = $(element);
3843
// are we excluding links to self?
39-
if (Ember.isPresent(link.attr('href')) && startsWith(link.attr('href'), origin) && excludeSelfLinks) {
44+
if (
45+
isPresent(link.attr("href")) &&
46+
startsWith(link.attr("href"), origin) &&
47+
excludeSelfLinks
48+
) {
4049
return;
4150
}
4251
// got this far, then apply a target if it hasn't already got one
43-
if (Ember.isEmpty(link.attr('target'))) {
44-
link.attr('target', targetValue);
52+
if (isEmpty(link.attr("target"))) {
53+
link.attr("target", targetValue);
4554
}
4655
});
47-
})
56+
},
4857
});

addon/helpers/marked-down.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import Ember from 'ember';
1+
import { helper as buildHelper } from '@ember/component/helper';
2+
import { htmlSafe } from '@ember/template';
3+
import EmberObject from '@ember/object';
4+
import { isEmpty, isBlank } from '@ember/utils';
25
import showdown from 'showdown';
36

47
export function markedDown(src, hash) {
5-
if (Ember.isEmpty(src) || Ember.isBlank(src[0])) {
8+
if (isEmpty(src) || isBlank(src[0])) {
69
return '';
710
}
8-
const converter = new showdown.Converter(Ember.Object.create(hash));
9-
return Ember.String.htmlSafe(converter.makeHtml(src[0].toString()));
11+
const converter = new showdown.Converter(EmberObject.create(hash));
12+
return htmlSafe(converter.makeHtml(src[0].toString()));
1013
}
1114

12-
export default Ember.Helper.helper(markedDown);
15+
export default buildHelper(markedDown);

addon/services/showdown-converter.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1+
import EmberObject from '@ember/object';
2+
import { isEmpty } from '@ember/utils';
3+
import { getOwner } from '@ember/application';
4+
import { on } from '@ember/object/evented';
5+
import Service from '@ember/service';
16
import Ember from 'ember';
27
import showdown from 'showdown';
38

4-
export default Ember.Service.extend({
9+
export default Service.extend({
510
/**
611
* When initializing the Service set all of the globals according to the values found in the `environment.js`.
712
*/
8-
_instantiateConverter: Ember.on('init', function () {
13+
_instantiateConverter: on('init', function () {
914
this._setShowdownGlobals();
1015
}),
1116
_setShowdownGlobals() {
1217
// grab the application configuration
13-
const config = Ember.getOwner(this).resolveRegistration('config:environment');
18+
const config = getOwner(this).resolveRegistration('config:environment');
1419
// set showdown global settings from the environment
15-
if (Ember.isEmpty(config.APP.showdown)) {
20+
if (isEmpty(config.APP.showdown)) {
1621
Ember.Logger.info('The `ember-cli-marked-down` addon will use ShowdownJS defaults to create the Converters.');
1722
Ember.Logger.info('If you want to customize ShowdownJS behaviour, please see the ember-cli-marked-down README: https://github.com/cybertoothca/ember-cli-marked-down#showdownjs-configuration-optional');
1823
return;
1924
}
20-
const showdownConfig = Ember.Object.create(config.APP.showdown);
25+
const showdownConfig = EmberObject.create(config.APP.showdown);
2126
// setting details can be found here: https://github.com/showdownjs/showdown#valid-options
2227
Object.keys(showdownConfig).forEach((key) => {
2328
showdown.setOption(key, showdownConfig.get(key));
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import Ember from 'ember';
1+
import Route from '@ember/routing/route';
22

3-
export default Ember.Route.extend({});
3+
export default Route.extend({});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import Ember from 'ember';
1+
import Route from '@ember/routing/route';
22

3-
export default Ember.Route.extend({});
3+
export default Route.extend({});

tests/dummy/app/routes/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import Ember from 'ember';
1+
import Route from '@ember/routing/route';
22

3-
export default Ember.Route.extend({});
3+
export default Route.extend({});

tests/unit/initializers/showdown-converter-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import Ember from 'ember';
1+
import Application from '@ember/application';
2+
import { run } from '@ember/runloop';
23
import ShowdownConverterInitializer from 'dummy/initializers/showdown-converter';
34
import { module, test } from 'qunit';
45

56
let application;
67

78
module('Unit | Initializer | showdown converter', {
89
beforeEach() {
9-
Ember.run(function () {
10-
application = Ember.Application.create();
10+
run(function () {
11+
application = Application.create();
1112
application.deferReadiness();
1213
});
1314
}

0 commit comments

Comments
 (0)