1212//! This is sufficient as a static parse tree, but don't build a
1313//! web browser using it. :)
1414
15- use std:: ascii:: AsciiExt ;
1615use std:: cell:: { RefCell , Cell } ;
1716use std:: collections:: HashSet ;
1817use std:: default:: Default ;
@@ -33,7 +32,7 @@ use serialize::{Serialize, Serializer};
3332use serialize:: TraversalScope ;
3433use serialize:: TraversalScope :: { IncludeNode , ChildrenOnly } ;
3534
36- pub use self :: ElementEnum :: { AnnotationXml , Normal , Script , Template } ;
35+ pub use self :: ElementEnum :: { Normal , Script , Template } ;
3736pub use self :: NodeEnum :: { Document , Doctype , Text , Comment , Element , PI } ;
3837
3938/// The different kinds of elements in the DOM.
@@ -45,11 +44,6 @@ pub enum ElementEnum {
4544 /// A template element and its template contents.
4645 /// https://html.spec.whatwg.org/multipage/#template-contents
4746 Template ( Handle ) ,
48- /// An annotation-xml element in the MathML namespace whose start tag token had an attribute
49- /// with the name "encoding" whose value was an ASCII case-insensitive match for the string
50- /// "text/html" or "application/xhtml+xml"
51- /// https://html.spec.whatwg.org/multipage/embedded-content.html#math:annotation-xml
52- AnnotationXml ( bool ) ,
5347}
5448
5549/// The different kinds of nodes in the DOM.
@@ -196,18 +190,20 @@ impl TreeSink for RcDom {
196190 } ;
197191 }
198192
193+ fn elem_any_attr < P > ( & self , target : & Self :: Handle , mut predicate : P ) -> bool
194+ where P : FnMut ( ExpandedName , & str ) -> bool {
195+ return match target. node {
196+ Element ( _, _, ref attrs) => {
197+ attrs. borrow ( ) . iter ( ) . any ( |a| predicate ( a. name . expanded ( ) , & * a. value ) )
198+ }
199+ _ => panic ! ( "not an element!" ) ,
200+ } ;
201+ }
202+
199203 fn create_element ( & mut self , name : QualName , attrs : Vec < Attribute > ) -> Handle {
200204 let info = match name. expanded ( ) {
201205 expanded_name ! ( html "script" ) => Script ( Cell :: new ( false ) ) ,
202206 expanded_name ! ( html "template" ) => Template ( new_node ( Document ) ) ,
203- expanded_name ! ( mathml "annotation-xml" ) => {
204- AnnotationXml ( attrs. iter ( )
205- . find ( |attr| attr. name . expanded ( ) == expanded_name ! ( "" , "encoding" ) )
206- . map_or ( false , |attr| {
207- attr. value . eq_ignore_ascii_case ( "text/html" ) ||
208- attr. value . eq_ignore_ascii_case ( "application/xhtml+xml" )
209- } ) )
210- } ,
211207 _ => Normal ,
212208 } ;
213209 new_node ( Element ( name, info, RefCell :: new ( attrs) ) )
@@ -319,13 +315,6 @@ impl TreeSink for RcDom {
319315 panic ! ( "not a script element!" ) ;
320316 }
321317 }
322-
323- fn is_mathml_annotation_xml_integration_point ( & self , handle : & Handle ) -> bool {
324- match handle. node {
325- Element ( _, AnnotationXml ( ret) , _) => ret,
326- _ => unreachable ! ( ) ,
327- }
328- }
329318}
330319
331320impl Default for RcDom {
0 commit comments