File tree Expand file tree Collapse file tree 5 files changed +16
-19
lines changed Expand file tree Collapse file tree 5 files changed +16
-19
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ test("invalid style", (t) => {
64
64
65
65
const inlinedHtml = `<html><head>
66
66
67
- <link href="/rss.xml" rel="alternate " title="RSS" type="application /rss+ xml">
67
+ <link rel="alternate" type="application/rss+xml " title="RSS" href=" /rss. xml">
68
68
69
69
</head>
70
70
<body>
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ def test_remote_stylesheet(href, kwargs):
118
118
inlined
119
119
== """<html><head>
120
120
121
- <link href="/rss.xml" rel="alternate " title="RSS" type="application /rss+ xml">
121
+ <link rel="alternate" type="application/rss+xml " title="RSS" href=" /rss. xml">
122
122
123
123
</head>
124
124
<body>
Original file line number Diff line number Diff line change @@ -160,30 +160,27 @@ impl Attributes {
160
160
let attr = attributes. swap_remove ( idx) ;
161
161
class = Some ( Class :: new ( attr. value ) ) ;
162
162
}
163
- attributes. sort_unstable_by ( |a, b| a. name . cmp ( & b. name ) ) ;
164
163
Attributes { attributes, class }
165
164
}
166
165
167
- pub ( crate ) fn find ( & self , needle : & QualName ) -> Option < usize > {
168
- if let Ok ( idx) = self
169
- . attributes
170
- . binary_search_by ( |probe| probe. name . cmp ( needle) )
171
- {
172
- Some ( idx)
173
- } else {
174
- None
175
- }
166
+ pub ( crate ) fn find ( & self , needle : & QualName ) -> Option < & str > {
167
+ self . attributes . iter ( ) . find_map ( |probe| {
168
+ if probe. name == * needle {
169
+ Some ( & * probe. value )
170
+ } else {
171
+ None
172
+ }
173
+ } )
176
174
}
177
175
178
176
/// Checks if the attributes map contains a given local name.
179
177
pub ( crate ) fn contains ( & self , local : html5ever:: LocalName ) -> bool {
180
- let needle = QualName :: new ( None , ns ! ( ) , local) ;
181
- self . find ( & needle) . is_some ( )
178
+ self . get ( local) . is_some ( )
182
179
}
183
180
184
181
/// Get the value of the attribute with the given local name, if it exists.
185
182
pub ( crate ) fn get ( & self , local : html5ever:: LocalName ) -> Option < & str > {
186
183
let needle = QualName :: new ( None , ns ! ( ) , local) ;
187
- self . find ( & needle) . map ( |idx| & * self . attributes [ idx ] . value )
184
+ self . find ( & needle)
188
185
}
189
186
}
Original file line number Diff line number Diff line change @@ -163,7 +163,6 @@ impl<'a> selectors::Element for Element<'a> {
163
163
ns_url. clone ( ) ,
164
164
local_name. clone ( ) . into_inner ( ) ,
165
165
) )
166
- . map ( |idx| & * attrs. attributes [ idx] . value )
167
166
. map_or ( false , |value| operation. eval_str ( value) ) ,
168
167
}
169
168
}
Original file line number Diff line number Diff line change @@ -231,11 +231,12 @@ impl TreeSink for Sink {
231
231
. expect ( "not an element" ) ;
232
232
let attributes = & mut element. attributes ;
233
233
for attr in attrs {
234
- if let Err ( idx ) = attributes
234
+ if attributes
235
235
. attributes
236
- . binary_search_by ( |entry| entry. name . cmp ( & attr. name ) )
236
+ . iter ( )
237
+ . any ( |entry| entry. name == attr. name )
237
238
{
238
- attributes. attributes . insert ( idx , attr) ;
239
+ attributes. attributes . push ( attr) ;
239
240
}
240
241
}
241
242
}
You can’t perform that action at this time.
0 commit comments