| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // WARNING: Do not edit - generated code. | 5 // WARNING: Do not edit - generated code. |
| 6 | 6 |
| 7 part of $LIBRARYNAME; | 7 part of $LIBRARYNAME; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Model-Driven Views (MDV)'s native features enables a wide-range of use cases, | 10 * Model-Driven Views (MDV)'s native features enables a wide-range of use cases, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 throw new ArgumentError('instanceRef should not be supplied for ' | 145 throw new ArgumentError('instanceRef should not be supplied for ' |
| 146 'attribute templates.'); | 146 'attribute templates.'); |
| 147 } | 147 } |
| 148 templateElement = _extractTemplateFromAttributeTemplate(template); | 148 templateElement = _extractTemplateFromAttributeTemplate(template); |
| 149 templateElement._templateIsDecorated = true; | 149 templateElement._templateIsDecorated = true; |
| 150 isNative = templateElement is TemplateElement; | 150 isNative = templateElement is TemplateElement; |
| 151 liftRoot = true; | 151 liftRoot = true; |
| 152 } | 152 } |
| 153 | 153 |
| 154 if (!isNative) { | 154 if (!isNative) { |
| 155 var doc = _getTemplateContentsOwner(templateElement.document); | 155 var doc = _getTemplateContentsOwner(templateElement.ownerDocument); |
| 156 templateElement._templateContent = doc.createDocumentFragment(); | 156 templateElement._templateContent = doc.createDocumentFragment(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 if (instanceRef != null) { | 159 if (instanceRef != null) { |
| 160 // template is contained within an instance, its direct content must be | 160 // template is contained within an instance, its direct content must be |
| 161 // empty | 161 // empty |
| 162 templateElement._templateInstanceRef = instanceRef; | 162 templateElement._templateInstanceRef = instanceRef; |
| 163 } else if (liftContents) { | 163 } else if (liftContents) { |
| 164 _liftNonNativeChildrenIntoContent(templateElement, template, liftRoot); | 164 _liftNonNativeChildrenIntoContent(templateElement, template, liftRoot); |
| 165 } else if (bootstrapContents) { | 165 } else if (bootstrapContents) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 194 // <tr template repeat="{{ foo }}"" class="bar"><td>Bar</td></tr> | 194 // <tr template repeat="{{ foo }}"" class="bar"><td>Bar</td></tr> |
| 195 // | 195 // |
| 196 // becomes | 196 // becomes |
| 197 // | 197 // |
| 198 // <template repeat="{{ foo }}"> | 198 // <template repeat="{{ foo }}"> |
| 199 // + #document-fragment | 199 // + #document-fragment |
| 200 // + <tr class="bar"> | 200 // + <tr class="bar"> |
| 201 // + <td>Bar</td> | 201 // + <td>Bar</td> |
| 202 // | 202 // |
| 203 static Element _extractTemplateFromAttributeTemplate(Element el) { | 203 static Element _extractTemplateFromAttributeTemplate(Element el) { |
| 204 var template = el.document.createElement('template'); | 204 var template = el.ownerDocument.createElement('template'); |
| 205 el.parentNode.insertBefore(template, el); | 205 el.parentNode.insertBefore(template, el); |
| 206 | 206 |
| 207 for (var name in el.attributes.keys.toList()) { | 207 for (var name in el.attributes.keys.toList()) { |
| 208 switch (name) { | 208 switch (name) { |
| 209 case 'template': | 209 case 'template': |
| 210 el.attributes.remove(name); | 210 el.attributes.remove(name); |
| 211 break; | 211 break; |
| 212 case 'repeat': | 212 case 'repeat': |
| 213 case 'bind': | 213 case 'bind': |
| 214 case 'ref': | 214 case 'ref': |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 static void bootstrap(Node content) { | 247 static void bootstrap(Node content) { |
| 248 void _bootstrap(template) { | 248 void _bootstrap(template) { |
| 249 if (!TemplateElement.decorate(template)) { | 249 if (!TemplateElement.decorate(template)) { |
| 250 bootstrap(template.content); | 250 bootstrap(template.content); |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 // Need to do this first as the contents may get lifted if |node| is | 254 // Need to do this first as the contents may get lifted if |node| is |
| 255 // template. | 255 // template. |
| 256 // TODO(jmesserly): content is DocumentFragment or Element | 256 // TODO(jmesserly): content is DocumentFragment or Element |
| 257 var descendents = | 257 var descendents = |
| 258 (content as dynamic).querySelectorAll(_allTemplatesSelectors); | 258 (content as dynamic).querySelectorAll(_allTemplatesSelectors); |
| 259 if (content is Element && (content as Element).isTemplate) { | 259 if (content is Element && (content as Element).isTemplate) { |
| 260 _bootstrap(content); | 260 _bootstrap(content); |
| 261 } | 261 } |
| 262 | 262 |
| 263 descendents.forEach(_bootstrap); | 263 descendents.forEach(_bootstrap); |
| 264 } | 264 } |
| 265 | 265 |
| 266 static final String _allTemplatesSelectors = | 266 static final String _allTemplatesSelectors = |
| 267 'template, option[template], optgroup[template], ' + | 267 'template, option[template], optgroup[template], ' + |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 */ | 300 */ |
| 301 void setInnerHtml(String html, | 301 void setInnerHtml(String html, |
| 302 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { | 302 {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { |
| 303 text = null; | 303 text = null; |
| 304 var fragment = createFragment( | 304 var fragment = createFragment( |
| 305 html, validator: validator, treeSanitizer: treeSanitizer); | 305 html, validator: validator, treeSanitizer: treeSanitizer); |
| 306 | 306 |
| 307 content.append(fragment); | 307 content.append(fragment); |
| 308 } | 308 } |
| 309 } | 309 } |
| OLD | NEW |