Skip to content

Commit

Permalink
fix(PAL): support for pal-nodejs
Browse files Browse the repository at this point in the history
window and Element injects are now requested via the PAL
so that executing tests with node-based unit test runners like
Jest do not break

related issue #243
  • Loading branch information
zewa666 committed Nov 8, 2017
1 parent 42ec461 commit 66412a8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"karma-jspm": "^2.2.0",
"merge2": "^1.0.2",
"object.assign": "^4.0.4",
"require-dir": "^0.3.0",
"require-dir": "^0.3.2",
"run-sequence": "^1.2.2",
"through2": "^2.0.1",
"typedoc": "^0.4.4",
Expand Down
4 changes: 2 additions & 2 deletions src/aurelia-i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function configure(frameworkConfig, cb): Promise<void> {
frameworkConfig.globalResources(PLATFORM.moduleName('./rt'));

// check whether Intl is available, otherwise load the polyfill
if (window.Intl === undefined) {
if (PLATFORM.global.Intl === undefined) {
let i18nLogger = LogManager.getLogger('i18n');
i18nLogger.warn('Intl API is not available. Trying to load the polyfill.');
let loader = frameworkConfig.container.get(Loader);
Expand All @@ -73,7 +73,7 @@ function configure(frameworkConfig, cb): Promise<void> {
return loader.normalize('aurelia-i18n').then((i18nName) => {
return loader.normalize('intl', i18nName).then((intlName) => {
return loader.loadModule(intlName).then((poly) => {
window.Intl = poly;
PLATFORM.global.Intl = poly;
return registerI18N(frameworkConfig, cb);
}, () => i18nLogger.warn('Failed to load the Intl polyfill.'));
}, () => i18nLogger.warn(normalizeErrorMessage.replace('{module}', 'intl')));
Expand Down
3 changes: 2 additions & 1 deletion src/base-i18n.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {I18N} from './i18n';
import {DOM} from 'aurelia-pal';
import {EventAggregator} from 'aurelia-event-aggregator';

export class BaseI18N {

static inject = [I18N, Element, EventAggregator];
static inject = [I18N, DOM.Element, EventAggregator];

constructor(i18n, element, ea) {
this.i18n = i18n;
Expand Down
4 changes: 2 additions & 2 deletions src/i18n.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*eslint no-cond-assign: 0*/
import * as LogManager from 'aurelia-logging';
import i18next from 'i18next';
import {DOM} from 'aurelia-pal';
import {DOM, PLATFORM} from 'aurelia-pal';
import {EventAggregator} from 'aurelia-event-aggregator';
import {BindingSignaler} from 'aurelia-templating-resources';

Expand All @@ -20,7 +20,7 @@ export class I18N {
constructor(ea, signaler) {
this.i18next = i18next;
this.ea = ea;
this.Intl = window.Intl;
this.Intl = PLATFORM.global.Intl;
this.signaler = signaler;
this.i18nextDefered.promise = new Promise((resolve) => this.i18nextDefered.resolve = resolve);
}
Expand Down
5 changes: 3 additions & 2 deletions src/t.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {metadata} from 'aurelia-metadata';
import {customAttribute, HtmlBehaviorResource} from 'aurelia-templating';
import {SignalBindingBehavior} from 'aurelia-templating-resources';
import {ValueConverter} from 'aurelia-binding';
import {DOM} from 'aurelia-pal';
import {LazyOptional} from './utils';


Expand All @@ -20,7 +21,7 @@ export class TValueConverter {

@customAttribute('t-params')
export class TParamsCustomAttribute {
static inject = [Element];
static inject = [DOM.Element];
static configureAliases(aliases) {
let r = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, TParamsCustomAttribute);
r.aliases = aliases;
Expand All @@ -39,7 +40,7 @@ export class TParamsCustomAttribute {
@customAttribute('t')
export class TCustomAttribute {

static inject = [Element, I18N, EventAggregator, LazyOptional.of(TParamsCustomAttribute)];
static inject = [DOM.Element, I18N, EventAggregator, LazyOptional.of(TParamsCustomAttribute)];
static configureAliases(aliases) {
let r = metadata.getOrCreateOwn(metadata.resource, HtmlBehaviorResource, TCustomAttribute);
r.aliases = aliases;
Expand Down

0 comments on commit 66412a8

Please sign in to comment.