| 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 class _XMLClassSet extends _CssClassSet { | 5 class _XMLClassSet extends _CssClassSet { |
| 6 _XMLClassSet(element) : super(element); | 6 _XMLClassSet(element) : super(element); |
| 7 | 7 |
| 8 String _className() { | 8 String _className() { |
| 9 final classStr = _element.getAttribute('class'); | 9 final classStr = _element.getAttribute('class'); |
| 10 return classStr == null ? '' : classStr; | 10 return classStr == null ? '' : classStr; |
| 11 } | 11 } |
| 12 | 12 |
| 13 void _write(Set s) => _element.setAttribute('class', _formatSet(s)); | 13 void _write(Set s) => _element.setAttribute('class', _formatSet(s)); |
| 14 } | 14 } |
| 15 | 15 |
| 16 class XMLElementWrappingImplementation extends ElementWrappingImplementation | 16 class XMLElementWrappingImplementation extends ElementWrappingImplementation |
| 17 implements XMLElement { | 17 implements XMLElement { |
| 18 XMLElementWrappingImplementation._wrap(ptr) : super._wrap(ptr); | 18 XMLElementWrappingImplementation._wrap(ptr) : super._wrap(ptr); |
| 19 | 19 |
| 20 factory XMLElementWrappingImplementation.tag(String tag) => | 20 factory XMLElementWrappingImplementation.tag(String tag) => |
| 21 LevelDom.wrapElement(dom.document.createElementNS(null, tag)); | 21 LevelDom.wrapElement(dom.document.createElementNS(null, tag)); |
| 22 | 22 |
| 23 factory XMLElementWrappingImplementation.xml(String xml) { | 23 factory XMLElementWrappingImplementation.xml(String xml) { |
| 24 XMLElement parentTag = new XMLElement.tag('xml'); | 24 XMLElement parentTag = new XMLElement.tag('xml'); |
| 25 parentTag.innerHTML = xml; | 25 parentTag.innerHTML = xml; |
| 26 if (parentTag.nodes.length == 1) return parentTag.nodes.removeLast(); | 26 if (parentTag.nodes.length == 1) return parentTag.nodes.removeLast(); |
| 27 | 27 |
| 28 throw new IllegalArgumentException('XML had ${parentTag.nodes.length} ' + | 28 throw new IllegalArgumentException( |
| 29 'top-level nodes but 1 expected'); | 29 'XML had ${parentTag.nodes.length} top-level nodes but 1 expected'); |
| 30 } | 30 } |
| 31 | 31 |
| 32 Set<String> get classes() { | 32 Set<String> get classes() { |
| 33 if (_cssClassSet === null) { | 33 if (_cssClassSet === null) { |
| 34 _cssClassSet = new _XMLClassSet(_ptr); | 34 _cssClassSet = new _XMLClassSet(_ptr); |
| 35 } | 35 } |
| 36 return _cssClassSet; | 36 return _cssClassSet; |
| 37 } | 37 } |
| 38 | 38 |
| 39 ElementList get elements() { | 39 ElementList get elements() { |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 182 |
| 183 void set lang(String value) { attributes['lang'] = value; } | 183 void set lang(String value) { attributes['lang'] = value; } |
| 184 | 184 |
| 185 String get dir() => _attr('dir'); | 185 String get dir() => _attr('dir'); |
| 186 | 186 |
| 187 void set dir(String value) { attributes['dir'] = value; } | 187 void set dir(String value) { attributes['dir'] = value; } |
| 188 | 188 |
| 189 String _attr(String name, [String def = '']) => | 189 String _attr(String name, [String def = '']) => |
| 190 attributes.containsKey(name) ? attributes[name] : def; | 190 attributes.containsKey(name) ? attributes[name] : def; |
| 191 } | 191 } |
| OLD | NEW |