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

Side by Side Diff: tools/dom/src/Validators.dart

Issue 1369573004: Move JS calls out of Dartium code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
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 part of dart.dom.html; 5 part of dart.dom.html;
6 6
7 7
8 /** 8 /**
9 * Interface used to validate that only accepted elements and attributes are 9 * Interface used to validate that only accepted elements and attributes are
10 * allowed while parsing HTML strings into DOM nodes. 10 * allowed while parsing HTML strings into DOM nodes.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // allowing embeds seems quite unlikely. This is also the reason that we 202 // allowing embeds seems quite unlikely. This is also the reason that we
203 // can't declare the type of element, as an embed won't pass any type 203 // can't declare the type of element, as an embed won't pass any type
204 // check in dart2js. 204 // check in dart2js.
205 var corrupted = true; 205 var corrupted = true;
206 var attrs; 206 var attrs;
207 var isAttr; 207 var isAttr;
208 try { 208 try {
209 // If getting/indexing attributes throws, count that as corrupt. 209 // If getting/indexing attributes throws, count that as corrupt.
210 attrs = element.attributes; 210 attrs = element.attributes;
211 isAttr = attrs['is']; 211 isAttr = attrs['is'];
212 var corruptedTest1 = Element._hasCorruptedAttributes(element);
213
212 // On IE, erratically, the hasCorruptedAttributes test can return false, 214 // On IE, erratically, the hasCorruptedAttributes test can return false,
213 // even though it clearly is corrupted. A separate copy of the test 215 // even though it clearly is corrupted. A separate copy of the test
214 // inlining just the basic check seems to help. 216 // inlining just the basic check seems to help.
215 var corruptedTest1 = Element._hasCorruptedAttributes(element); 217 var corruptedTest2 = Element._hasCorruptedAttributesAdditionalCheck(elemen t);
216 var corruptedTest2 = JS('bool', r'!(#.attributes instanceof NamedNodeMap)' , element);
217 corrupted = corruptedTest1 || corruptedTest2; 218 corrupted = corruptedTest1 || corruptedTest2;
218 } catch(e) {} 219 } catch(e) {}
219 var elementText = 'element unprintable'; 220 var elementText = 'element unprintable';
220 try { 221 try {
221 elementText = element.toString(); 222 elementText = element.toString();
222 } catch(e) {} 223 } catch(e) {}
223 try { 224 try {
224 var elementTagName = Element._safeTagName(element); 225 var elementTagName = Element._safeTagName(element);
225 _sanitizeElement(element, parent, corrupted, elementText, elementTagName, 226 _sanitizeElement(element, parent, corrupted, elementText, elementTagName,
226 attrs, isAttr); 227 attrs, isAttr);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 case Node.COMMENT_NODE: 288 case Node.COMMENT_NODE:
288 case Node.DOCUMENT_FRAGMENT_NODE: 289 case Node.DOCUMENT_FRAGMENT_NODE:
289 case Node.TEXT_NODE: 290 case Node.TEXT_NODE:
290 case Node.CDATA_SECTION_NODE: 291 case Node.CDATA_SECTION_NODE:
291 break; 292 break;
292 default: 293 default:
293 _removeNode(node, parent); 294 _removeNode(node, parent);
294 } 295 }
295 } 296 }
296 } 297 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698