Permalink
Browse files

fix(PAL): support for pal-nodejs

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 66412a8c11bdd749eb3b7191b317e3bd9516b346
Showing with 10 additions and 8 deletions.
  1. +1 −1 package.json
  2. +2 −2 src/aurelia-i18n.js
  3. +2 −1 src/base-i18n.js
  4. +2 −2 src/i18n.js
  5. +3 −2 src/t.js
View
@@ -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",
View
@@ -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);
@@ -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')));
View
@@ -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;
View
@@ -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';
@@ -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);
}
View
@@ -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';
@@ -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;
@@ -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;

0 comments on commit 66412a8

Please sign in to comment.