| 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 * var myElement = new Element.tag('unknownTag'); | 347 * var myElement = new Element.tag('unknownTag'); |
| 348 * print(myElement is UnknownElement); // 'true' | 348 * print(myElement is UnknownElement); // 'true' |
| 349 * | 349 * |
| 350 * For standard elements it is more preferable to use the type constructors: | 350 * For standard elements it is more preferable to use the type constructors: |
| 351 * var element = new DivElement(); | 351 * var element = new DivElement(); |
| 352 * | 352 * |
| 353 * See also: | 353 * See also: |
| 354 * | 354 * |
| 355 * * [isTagSupported] | 355 * * [isTagSupported] |
| 356 */ | 356 */ |
| 357 factory $CLASSNAME.tag(String tag) => | 357 factory $CLASSNAME.tag(String tag, [String typeExtention]) => |
| 358 _$(CLASSNAME)FactoryProvider.createElement_tag(tag); | 358 _$(CLASSNAME)FactoryProvider.createElement_tag(tag, typeExtention); |
| 359 | 359 |
| 360 /// Creates a new `<a>` element. | 360 /// Creates a new `<a>` element. |
| 361 /// | 361 /// |
| 362 /// This is identical to calling `new Element.tag('a')`. | 362 /// This is identical to calling `new Element.tag('a')`. |
| 363 factory Element.a() => new Element.tag('a'); | 363 factory Element.a() => new Element.tag('a'); |
| 364 | 364 |
| 365 /// Creates a new `<article>` element. | 365 /// Creates a new `<article>` element. |
| 366 /// | 366 /// |
| 367 /// This is identical to calling `new Element.tag('article')`. | 367 /// This is identical to calling `new Element.tag('article')`. |
| 368 factory Element.article() => new Element.tag('article'); | 368 factory Element.article() => new Element.tag('article'); |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 void appendHtml(String text) { | 665 void appendHtml(String text) { |
| 666 this.insertAdjacentHtml('beforeend', text); | 666 this.insertAdjacentHtml('beforeend', text); |
| 667 } | 667 } |
| 668 | 668 |
| 669 /** | 669 /** |
| 670 * Checks to see if the tag name is supported by the current platform. | 670 * Checks to see if the tag name is supported by the current platform. |
| 671 * | 671 * |
| 672 * The tag should be a valid HTML tag name. | 672 * The tag should be a valid HTML tag name. |
| 673 */ | 673 */ |
| 674 static bool isTagSupported(String tag) { | 674 static bool isTagSupported(String tag) { |
| 675 var e = _ElementFactoryProvider.createElement_tag(tag); | 675 var e = _ElementFactoryProvider.createElement_tag(tag, null); |
| 676 return e is Element && !(e is UnknownElement); | 676 return e is Element && !(e is UnknownElement); |
| 677 } | 677 } |
| 678 | 678 |
| 679 /** | 679 /** |
| 680 * Called by the DOM when this element has been instantiated. | 680 * Called by the DOM when this element has been instantiated. |
| 681 */ | 681 */ |
| 682 @Experimental() | 682 @Experimental() |
| 683 void created() {} | 683 void created() {} |
| 684 | 684 |
| 685 // Hooks to support custom WebComponents. | 685 // Hooks to support custom WebComponents. |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 $!MEMBERS | 1308 $!MEMBERS |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 | 1311 |
| 1312 class _ElementFactoryProvider { | 1312 class _ElementFactoryProvider { |
| 1313 | 1313 |
| 1314 @DomName('Document.createElement') | 1314 @DomName('Document.createElement') |
| 1315 $if DART2JS | 1315 $if DART2JS |
| 1316 // Optimization to improve performance until the dart2js compiler inlines this | 1316 // Optimization to improve performance until the dart2js compiler inlines this |
| 1317 // method. | 1317 // method. |
| 1318 static dynamic createElement_tag(String tag) => | 1318 static dynamic createElement_tag(String tag, String typeExtension) { |
| 1319 // Firefox may return a JS function for some types (Embed, Object). | 1319 // Firefox may return a JS function for some types (Embed, Object). |
| 1320 JS('Element|=Object', 'document.createElement(#)', tag); | 1320 if (typeExtension != null) { |
| 1321 return JS('Element|=Object', 'document.createElement(#, #)', |
| 1322 tag, typeExtension); |
| 1323 } |
| 1324 // Should be able to eliminate this and just call the two-arg version above |
| 1325 // with null typeExtension, but Chrome treats the tag as case-sensitive if |
| 1326 // typeExtension is null. |
| 1327 // https://code.google.com/p/chromium/issues/detail?id=282467 |
| 1328 return JS('Element|=Object', 'document.createElement(#)', tag); |
| 1329 } |
| 1330 |
| 1321 $else | 1331 $else |
| 1322 static Element createElement_tag(String tag) => | 1332 static Element createElement_tag(String tag, String typeExtension) => |
| 1323 document.$dom_createElement(tag); | 1333 document.$dom_createElement(tag, typeExtension); |
| 1324 $endif | 1334 $endif |
| 1325 } | 1335 } |
| 1326 | 1336 |
| 1327 | 1337 |
| 1328 /** | 1338 /** |
| 1329 * Options for Element.scrollIntoView. | 1339 * Options for Element.scrollIntoView. |
| 1330 */ | 1340 */ |
| 1331 class ScrollAlignment { | 1341 class ScrollAlignment { |
| 1332 final _value; | 1342 final _value; |
| 1333 const ScrollAlignment._internal(this._value); | 1343 const ScrollAlignment._internal(this._value); |
| 1334 toString() => 'ScrollAlignment.$_value'; | 1344 toString() => 'ScrollAlignment.$_value'; |
| 1335 | 1345 |
| 1336 /// Attempt to align the element to the top of the scrollable area. | 1346 /// Attempt to align the element to the top of the scrollable area. |
| 1337 static const TOP = const ScrollAlignment._internal('TOP'); | 1347 static const TOP = const ScrollAlignment._internal('TOP'); |
| 1338 /// Attempt to center the element in the scrollable area. | 1348 /// Attempt to center the element in the scrollable area. |
| 1339 static const CENTER = const ScrollAlignment._internal('CENTER'); | 1349 static const CENTER = const ScrollAlignment._internal('CENTER'); |
| 1340 /// Attempt to align the element to the bottom of the scrollable area. | 1350 /// Attempt to align the element to the bottom of the scrollable area. |
| 1341 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); | 1351 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); |
| 1342 } | 1352 } |
| OLD | NEW |