| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 class _ChildrenElementList extends ListBase<Element> { | 7 class _ChildrenElementList extends ListBase<Element> { |
| 8 // Raw Element. | 8 // Raw Element. |
| 9 final Element _element; | 9 final Element _element; |
| 10 final HtmlCollection _childElements; | 10 final HtmlCollection _childElements; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 * var myElement = new Element.tag('unknownTag'); | 336 * var myElement = new Element.tag('unknownTag'); |
| 337 * print(myElement is UnknownElement); // 'true' | 337 * print(myElement is UnknownElement); // 'true' |
| 338 * | 338 * |
| 339 * For standard elements it is more preferable to use the type constructors: | 339 * For standard elements it is more preferable to use the type constructors: |
| 340 * var element = new DivElement(); | 340 * var element = new DivElement(); |
| 341 * | 341 * |
| 342 * See also: | 342 * See also: |
| 343 * | 343 * |
| 344 * * [isTagSupported] | 344 * * [isTagSupported] |
| 345 */ | 345 */ |
| 346 factory $CLASSNAME.tag(String tag) => | 346 factory $CLASSNAME.tag(String tag, [String typeExtention]) => |
| 347 _$(CLASSNAME)FactoryProvider.createElement_tag(tag); | 347 _$(CLASSNAME)FactoryProvider.createElement_tag(tag, typeExtention); |
| 348 | 348 |
| 349 /// Creates a new `<a>` element. | 349 /// Creates a new `<a>` element. |
| 350 /// | 350 /// |
| 351 /// This is identical to calling `new Element.tag('a')`. | 351 /// This is identical to calling `new Element.tag('a')`. |
| 352 factory Element.a() => new Element.tag('a'); | 352 factory Element.a() => new Element.tag('a'); |
| 353 | 353 |
| 354 /// Creates a new `<article>` element. | 354 /// Creates a new `<article>` element. |
| 355 /// | 355 /// |
| 356 /// This is identical to calling `new Element.tag('article')`. | 356 /// This is identical to calling `new Element.tag('article')`. |
| 357 factory Element.article() => new Element.tag('article'); | 357 factory Element.article() => new Element.tag('article'); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 void appendHtml(String text) { | 654 void appendHtml(String text) { |
| 655 this.insertAdjacentHtml('beforeend', text); | 655 this.insertAdjacentHtml('beforeend', text); |
| 656 } | 656 } |
| 657 | 657 |
| 658 /** | 658 /** |
| 659 * Checks to see if the tag name is supported by the current platform. | 659 * Checks to see if the tag name is supported by the current platform. |
| 660 * | 660 * |
| 661 * The tag should be a valid HTML tag name. | 661 * The tag should be a valid HTML tag name. |
| 662 */ | 662 */ |
| 663 static bool isTagSupported(String tag) { | 663 static bool isTagSupported(String tag) { |
| 664 var e = _ElementFactoryProvider.createElement_tag(tag); | 664 var e = _ElementFactoryProvider.createElement_tag(tag, null); |
| 665 return e is Element && !(e is UnknownElement); | 665 return e is Element && !(e is UnknownElement); |
| 666 } | 666 } |
| 667 | 667 |
| 668 /** | 668 /** |
| 669 * Called by the DOM when this element has been instantiated. | 669 * Called by the DOM when this element has been instantiated. |
| 670 */ | 670 */ |
| 671 @Experimental() | 671 @Experimental() |
| 672 void created() {} | 672 void created() {} |
| 673 | 673 |
| 674 // Hooks to support custom WebComponents. | 674 // Hooks to support custom WebComponents. |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 static Node _singleNode(List<Node> list) { | 1298 static Node _singleNode(List<Node> list) { |
| 1299 if (list.length == 1) return list[0]; | 1299 if (list.length == 1) return list[0]; |
| 1300 throw new ArgumentError('HTML had ${list.length} ' | 1300 throw new ArgumentError('HTML had ${list.length} ' |
| 1301 'top level elements but 1 expected'); | 1301 'top level elements but 1 expected'); |
| 1302 } | 1302 } |
| 1303 | 1303 |
| 1304 @DomName('Document.createElement') | 1304 @DomName('Document.createElement') |
| 1305 $if DART2JS | 1305 $if DART2JS |
| 1306 // Optimization to improve performance until the dart2js compiler inlines this | 1306 // Optimization to improve performance until the dart2js compiler inlines this |
| 1307 // method. | 1307 // method. |
| 1308 static dynamic createElement_tag(String tag) => | 1308 static dynamic createElement_tag(String tag, String typeExtension) => |
| 1309 // Firefox may return a JS function for some types (Embed, Object). | 1309 // Firefox may return a JS function for some types (Embed, Object). |
| 1310 JS('Element|=Object', 'document.createElement(#)', tag); | 1310 JS('Element|=Object', 'document.createElement(#, #)', tag, typeExtension); |
| 1311 $else | 1311 $else |
| 1312 static Element createElement_tag(String tag) => | 1312 static Element createElement_tag(String tag, String typeExtension) => |
| 1313 document.$dom_createElement(tag); | 1313 document.$dom_createElement(tag, typeExtension); |
| 1314 $endif | 1314 $endif |
| 1315 } | 1315 } |
| 1316 | 1316 |
| 1317 | 1317 |
| 1318 /** | 1318 /** |
| 1319 * Options for Element.scrollIntoView. | 1319 * Options for Element.scrollIntoView. |
| 1320 */ | 1320 */ |
| 1321 class ScrollAlignment { | 1321 class ScrollAlignment { |
| 1322 final _value; | 1322 final _value; |
| 1323 const ScrollAlignment._internal(this._value); | 1323 const ScrollAlignment._internal(this._value); |
| 1324 toString() => 'ScrollAlignment.$_value'; | 1324 toString() => 'ScrollAlignment.$_value'; |
| 1325 | 1325 |
| 1326 /// Attempt to align the element to the top of the scrollable area. | 1326 /// Attempt to align the element to the top of the scrollable area. |
| 1327 static const TOP = const ScrollAlignment._internal('TOP'); | 1327 static const TOP = const ScrollAlignment._internal('TOP'); |
| 1328 /// Attempt to center the element in the scrollable area. | 1328 /// Attempt to center the element in the scrollable area. |
| 1329 static const CENTER = const ScrollAlignment._internal('CENTER'); | 1329 static const CENTER = const ScrollAlignment._internal('CENTER'); |
| 1330 /// Attempt to align the element to the bottom of the scrollable area. | 1330 /// Attempt to align the element to the bottom of the scrollable area. |
| 1331 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); | 1331 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); |
| 1332 } | 1332 } |
| OLD | NEW |