Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: tools/dom/templates/html/impl/impl_Element.darttemplate

Issue 23442011: Revert "Revert "Basic functionality is working with JS native support and polyfill, still some issu… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 $!MEMBERS 1320 $!MEMBERS
1321 } 1321 }
1322 1322
1323 1323
1324 class _ElementFactoryProvider { 1324 class _ElementFactoryProvider {
1325 1325
1326 @DomName('Document.createElement') 1326 @DomName('Document.createElement')
1327 $if DART2JS 1327 $if DART2JS
1328 // Optimization to improve performance until the dart2js compiler inlines this 1328 // Optimization to improve performance until the dart2js compiler inlines this
1329 // method. 1329 // method.
1330 static dynamic createElement_tag(String tag) => 1330 static dynamic createElement_tag(String tag, String typeExtension) {
1331 // Firefox may return a JS function for some types (Embed, Object). 1331 // Firefox may return a JS function for some types (Embed, Object).
1332 JS('Element|=Object', 'document.createElement(#)', tag); 1332 if (typeExtension != null) {
1333 return JS('Element|=Object', 'document.createElement(#, #)',
1334 tag, typeExtension);
1335 }
1336 // Should be able to eliminate this and just call the two-arg version above
1337 // with null typeExtension, but Chrome treats the tag as case-sensitive if
1338 // typeExtension is null.
1339 // https://code.google.com/p/chromium/issues/detail?id=282467
1340 return JS('Element|=Object', 'document.createElement(#)', tag);
1341 }
1342
1333 $else 1343 $else
1334 static Element createElement_tag(String tag) => 1344 static Element createElement_tag(String tag, String typeExtension) =>
1335 document.$dom_createElement(tag); 1345 document.$dom_createElement(tag, typeExtension);
1336 $endif 1346 $endif
1337 } 1347 }
1338 1348
1339 1349
1340 /** 1350 /**
1341 * Options for Element.scrollIntoView. 1351 * Options for Element.scrollIntoView.
1342 */ 1352 */
1343 class ScrollAlignment { 1353 class ScrollAlignment {
1344 final _value; 1354 final _value;
1345 const ScrollAlignment._internal(this._value); 1355 const ScrollAlignment._internal(this._value);
1346 toString() => 'ScrollAlignment.$_value'; 1356 toString() => 'ScrollAlignment.$_value';
1347 1357
1348 /// Attempt to align the element to the top of the scrollable area. 1358 /// Attempt to align the element to the top of the scrollable area.
1349 static const TOP = const ScrollAlignment._internal('TOP'); 1359 static const TOP = const ScrollAlignment._internal('TOP');
1350 /// Attempt to center the element in the scrollable area. 1360 /// Attempt to center the element in the scrollable area.
1351 static const CENTER = const ScrollAlignment._internal('CENTER'); 1361 static const CENTER = const ScrollAlignment._internal('CENTER');
1352 /// Attempt to align the element to the bottom of the scrollable area. 1362 /// Attempt to align the element to the bottom of the scrollable area.
1353 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); 1363 static const BOTTOM = const ScrollAlignment._internal('BOTTOM');
1354 } 1364 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698