| Index: sdk/lib/svg/dart2js/svg_dart2js.dart
|
| diff --git a/sdk/lib/svg/dart2js/svg_dart2js.dart b/sdk/lib/svg/dart2js/svg_dart2js.dart
|
| index a2bba24eef1e925886722c5c222b6430341df9dc..421a6af99eee81c9c48610eaeff98b538fdf2333 100644
|
| --- a/sdk/lib/svg/dart2js/svg_dart2js.dart
|
| +++ b/sdk/lib/svg/dart2js/svg_dart2js.dart
|
| @@ -3012,8 +3012,10 @@ class LengthList extends Object with ListMixin<Length>, ImmutableListMixin<Lengt
|
| @DocsEditable
|
| final int numberOfItems;
|
|
|
| - Length operator[](int index) => this.getItem(index);
|
| -
|
| + Length operator[](int index) {
|
| + if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
|
| + return this.getItem(index);
|
| + }
|
| void operator[]=(int index, Length value) {
|
| throw new UnsupportedError("Cannot assign element of immutable List.");
|
| }
|
| @@ -3027,6 +3029,34 @@ class LengthList extends Object with ListMixin<Length>, ImmutableListMixin<Lengt
|
| throw new UnsupportedError("Cannot resize immutable List.");
|
| }
|
|
|
| + Length get first {
|
| + if (this.length > 0) {
|
| + return JS('Length', '#[0]', this);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + Length get last {
|
| + int len = this.length;
|
| + if (len > 0) {
|
| + return JS('Length', '#[#]', this, len - 1);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + Length get single {
|
| + int len = this.length;
|
| + if (len == 1) {
|
| + return JS('Length', '#[0]', this);
|
| + }
|
| + if (len == 0) throw new StateError("No elements");
|
| + throw new StateError("More than one element");
|
| + }
|
| +
|
| + Length elementAt(int index) {
|
| + return this[index];
|
| + }
|
| +
|
| // -- end List<Length> mixins.
|
|
|
| @DomName('SVGLengthList.appendItem')
|
| @@ -3473,8 +3503,10 @@ class NumberList extends Object with ListMixin<Number>, ImmutableListMixin<Numbe
|
| @DocsEditable
|
| final int numberOfItems;
|
|
|
| - Number operator[](int index) => this.getItem(index);
|
| -
|
| + Number operator[](int index) {
|
| + if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
|
| + return this.getItem(index);
|
| + }
|
| void operator[]=(int index, Number value) {
|
| throw new UnsupportedError("Cannot assign element of immutable List.");
|
| }
|
| @@ -3488,6 +3520,34 @@ class NumberList extends Object with ListMixin<Number>, ImmutableListMixin<Numbe
|
| throw new UnsupportedError("Cannot resize immutable List.");
|
| }
|
|
|
| + Number get first {
|
| + if (this.length > 0) {
|
| + return JS('Number', '#[0]', this);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + Number get last {
|
| + int len = this.length;
|
| + if (len > 0) {
|
| + return JS('Number', '#[#]', this, len - 1);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + Number get single {
|
| + int len = this.length;
|
| + if (len == 1) {
|
| + return JS('Number', '#[0]', this);
|
| + }
|
| + if (len == 0) throw new StateError("No elements");
|
| + throw new StateError("More than one element");
|
| + }
|
| +
|
| + Number elementAt(int index) {
|
| + return this[index];
|
| + }
|
| +
|
| // -- end List<Number> mixins.
|
|
|
| @DomName('SVGNumberList.appendItem')
|
| @@ -4165,8 +4225,10 @@ class PathSegList extends Object with ListMixin<PathSeg>, ImmutableListMixin<Pat
|
| @DocsEditable
|
| final int numberOfItems;
|
|
|
| - PathSeg operator[](int index) => this.getItem(index);
|
| -
|
| + PathSeg operator[](int index) {
|
| + if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
|
| + return this.getItem(index);
|
| + }
|
| void operator[]=(int index, PathSeg value) {
|
| throw new UnsupportedError("Cannot assign element of immutable List.");
|
| }
|
| @@ -4180,6 +4242,34 @@ class PathSegList extends Object with ListMixin<PathSeg>, ImmutableListMixin<Pat
|
| throw new UnsupportedError("Cannot resize immutable List.");
|
| }
|
|
|
| + PathSeg get first {
|
| + if (this.length > 0) {
|
| + return JS('PathSeg', '#[0]', this);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + PathSeg get last {
|
| + int len = this.length;
|
| + if (len > 0) {
|
| + return JS('PathSeg', '#[#]', this, len - 1);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + PathSeg get single {
|
| + int len = this.length;
|
| + if (len == 1) {
|
| + return JS('PathSeg', '#[0]', this);
|
| + }
|
| + if (len == 0) throw new StateError("No elements");
|
| + throw new StateError("More than one element");
|
| + }
|
| +
|
| + PathSeg elementAt(int index) {
|
| + return this[index];
|
| + }
|
| +
|
| // -- end List<PathSeg> mixins.
|
|
|
| @DomName('SVGPathSegList.appendItem')
|
| @@ -4887,8 +4977,10 @@ class StringList extends Object with ListMixin<String>, ImmutableListMixin<Strin
|
| @DocsEditable
|
| final int numberOfItems;
|
|
|
| - String operator[](int index) => this.getItem(index);
|
| -
|
| + String operator[](int index) {
|
| + if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
|
| + return this.getItem(index);
|
| + }
|
| void operator[]=(int index, String value) {
|
| throw new UnsupportedError("Cannot assign element of immutable List.");
|
| }
|
| @@ -4902,6 +4994,34 @@ class StringList extends Object with ListMixin<String>, ImmutableListMixin<Strin
|
| throw new UnsupportedError("Cannot resize immutable List.");
|
| }
|
|
|
| + String get first {
|
| + if (this.length > 0) {
|
| + return JS('String', '#[0]', this);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + String get last {
|
| + int len = this.length;
|
| + if (len > 0) {
|
| + return JS('String', '#[#]', this, len - 1);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + String get single {
|
| + int len = this.length;
|
| + if (len == 1) {
|
| + return JS('String', '#[0]', this);
|
| + }
|
| + if (len == 0) throw new StateError("No elements");
|
| + throw new StateError("More than one element");
|
| + }
|
| +
|
| + String elementAt(int index) {
|
| + return this[index];
|
| + }
|
| +
|
| // -- end List<String> mixins.
|
|
|
| @DomName('SVGStringList.appendItem')
|
| @@ -5882,8 +6002,10 @@ class TransformList extends Object with ListMixin<Transform>, ImmutableListMixin
|
| @DocsEditable
|
| final int numberOfItems;
|
|
|
| - Transform operator[](int index) => this.getItem(index);
|
| -
|
| + Transform operator[](int index) {
|
| + if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
|
| + return this.getItem(index);
|
| + }
|
| void operator[]=(int index, Transform value) {
|
| throw new UnsupportedError("Cannot assign element of immutable List.");
|
| }
|
| @@ -5897,6 +6019,34 @@ class TransformList extends Object with ListMixin<Transform>, ImmutableListMixin
|
| throw new UnsupportedError("Cannot resize immutable List.");
|
| }
|
|
|
| + Transform get first {
|
| + if (this.length > 0) {
|
| + return JS('Transform', '#[0]', this);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + Transform get last {
|
| + int len = this.length;
|
| + if (len > 0) {
|
| + return JS('Transform', '#[#]', this, len - 1);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + Transform get single {
|
| + int len = this.length;
|
| + if (len == 1) {
|
| + return JS('Transform', '#[0]', this);
|
| + }
|
| + if (len == 0) throw new StateError("No elements");
|
| + throw new StateError("More than one element");
|
| + }
|
| +
|
| + Transform elementAt(int index) {
|
| + return this[index];
|
| + }
|
| +
|
| // -- end List<Transform> mixins.
|
|
|
| @DomName('SVGTransformList.appendItem')
|
| @@ -6238,8 +6388,10 @@ class _ElementInstanceList extends Object with ListMixin<ElementInstance>, Immut
|
| @DocsEditable
|
| int get length => JS("int", "#.length", this);
|
|
|
| - ElementInstance operator[](int index) => this.item(index);
|
| -
|
| + ElementInstance operator[](int index) {
|
| + if (JS("bool", "# >>> 0 !== # || # >= #", index, index, index, length)) throw new RangeError.range(index, 0, length);
|
| + return this.item(index);
|
| + }
|
| void operator[]=(int index, ElementInstance value) {
|
| throw new UnsupportedError("Cannot assign element of immutable List.");
|
| }
|
| @@ -6251,6 +6403,34 @@ class _ElementInstanceList extends Object with ListMixin<ElementInstance>, Immut
|
| throw new UnsupportedError("Cannot resize immutable List.");
|
| }
|
|
|
| + ElementInstance get first {
|
| + if (this.length > 0) {
|
| + return JS('ElementInstance', '#[0]', this);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + ElementInstance get last {
|
| + int len = this.length;
|
| + if (len > 0) {
|
| + return JS('ElementInstance', '#[#]', this, len - 1);
|
| + }
|
| + throw new StateError("No elements");
|
| + }
|
| +
|
| + ElementInstance get single {
|
| + int len = this.length;
|
| + if (len == 1) {
|
| + return JS('ElementInstance', '#[0]', this);
|
| + }
|
| + if (len == 0) throw new StateError("No elements");
|
| + throw new StateError("More than one element");
|
| + }
|
| +
|
| + ElementInstance elementAt(int index) {
|
| + return this[index];
|
| + }
|
| +
|
| // -- end List<ElementInstance> mixins.
|
|
|
| @DomName('SVGElementInstanceList.item')
|
|
|