前回に引き続き、現行日本語版と最新のdocs.htmlの違いについて紹介します。なお、ソースコードはdocs.html からの引用です。
docs.htmlの変更 (4/13)wi
IE9対応
Aureliaは何もしなければIE11からの対応ですが、IE9以上で動かす方法がドキュメントに追加されました。MutationObserverとWeakMap(MutationObserverが依存している)をjspmでインストールし、system.js の前に読み込めばいいそうです。
> jspm install "github:webreflection/es6-collections"
> jspm install "github:github:polymer/mutationobservers"
index.htmlで、
<script src="jspm_packages/github/webreflection/es6-collections@master/es6-collections.js"></script>
<script src="jspm_packages/github/polymer/mutationobservers@0.4.2/MutationObserver.js"></script>
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
aurelia.use.es5()
今までES5を使う場合にはconfigureで aurelia.use.es5()
を呼べと書いてありましたが、無くなっています。必要なくなったのかな。
decoratorが使えないとき: Decoratorsヘルパ
CoffeeScriptなど、decoratorが使えない場合のために、Decoratorsヘルパが用意されています。これをdecoratorsスタティックプロパティ、もしくはスタティックメソッドで宣言するだけです。
HttpClient = require('aurelia-http-client').HttpClient;
Decorators = require('aurelia-framework').Decorators;
class CustomerDetail
constructor: (@http) ->
@decorators:Decorators.transient().inject(HttpClient);
現行のTypeScriptで使う場合もこちらでいけそうですね。
Attached Behavior から Custom Attributeへ
Aureliaにはカスタムタグの他に、属性を追加することも出来ますが、これを今までは "Attached Behavior" と呼んでいました。これが、いつのまにかCustom Attributeになったようです。挙動が変わったのか、経緯は後で調べてみようと思いますが、ビヘイビアって翻訳しづらかったので(字面から意味がわからないという意味で)、ありがたい変更でした。