|
1 | 1 | //! Converts custom attributes `algorithm=""` and `var-scope=""` to `data-` |
2 | | -//! equivalents, to preserve validity of the output document. Errors on |
3 | | -//! `<var>`s outside of those scopes, unless the `<var>` has an `ignore=""` |
4 | | -//! attribute. |
5 | | -//! |
6 | | -//! TODO: check for `<var>`s inside of these scopes that are only used once, and |
7 | | -//! error when such lone `<var>`s are encountered. |
| 2 | +//! equivalents, to preserve validity of the output document. |
| 3 | +// |
| 4 | +// TODO: error on `<var>`s outside of those scopes, unless the `<var>` has an |
| 5 | +// `ignore=""` attribute. (This code is present but disabled until |
| 6 | +// https://github.com/whatwg/html/pull/11392 is merged.) |
| 7 | +// |
| 8 | +// TODO: check for `<var>`s inside of these scopes that are only used once, and |
| 9 | +// error when such lone `<var>`s are encountered. |
8 | 10 |
|
9 | 11 | use std::fmt::Write as _; |
10 | 12 | use std::io; |
@@ -180,12 +182,14 @@ impl<'a> Processor<'a> { |
180 | 182 | } |
181 | 183 | return Err(io::Error::new(io::ErrorKind::InvalidData, msgs.join("\n"))); |
182 | 184 | } |
183 | | - if !self.var_out_of_scope_msgs.is_empty() { |
184 | | - return Err(io::Error::new( |
185 | | - io::ErrorKind::InvalidData, |
186 | | - self.var_out_of_scope_msgs.join("\n"), |
187 | | - )); |
188 | | - } |
| 185 | + |
| 186 | + // Disabled until https://github.com/whatwg/html/pull/11392 is merged. |
| 187 | + // if !self.var_out_of_scope_msgs.is_empty() { |
| 188 | + // return Err(io::Error::new( |
| 189 | + // io::ErrorKind::InvalidData, |
| 190 | + // self.var_out_of_scope_msgs.join("\n"), |
| 191 | + // )); |
| 192 | + // } |
189 | 193 |
|
190 | 194 | let old_algorithm = QualName::new(None, ns!(), LocalName::from("algorithm")); |
191 | 195 | let new_algorithm = QualName::new(None, ns!(), LocalName::from("data-algorithm")); |
@@ -325,24 +329,25 @@ mod tests { |
325 | 329 | ); |
326 | 330 | } |
327 | 331 |
|
328 | | - #[tokio::test] |
329 | | - async fn test_var_outside_scope_errors() { |
330 | | - let parsed = parse_document_async( |
331 | | - r##"<!DOCTYPE html> |
332 | | -<p>Outside scope <var>bar</var></p> |
333 | | -"## |
334 | | - .as_bytes(), |
335 | | - ) |
336 | | - .await |
337 | | - .unwrap(); |
338 | | - let document = parsed.document().clone(); |
339 | | - |
340 | | - let mut proc = Processor::new(&parsed); |
341 | | - dom_utils::scan_dom(&document, &mut |h| proc.visit(h)); |
342 | | - let result = proc.apply(); |
343 | | - let err = result.unwrap_err(); |
344 | | - assert!(err.to_string().contains("Line 2: ")); |
345 | | - } |
| 332 | +// Disabled until https://github.com/whatwg/html/pull/11392 is merged. |
| 333 | +// #[tokio::test] |
| 334 | +// async fn test_var_outside_scope_errors() { |
| 335 | +// let parsed = parse_document_async( |
| 336 | +// r##"<!DOCTYPE html> |
| 337 | +// <p>Outside scope <var>bar</var></p> |
| 338 | +// "## |
| 339 | +// .as_bytes(), |
| 340 | +// ) |
| 341 | +// .await |
| 342 | +// .unwrap(); |
| 343 | +// let document = parsed.document().clone(); |
| 344 | + |
| 345 | +// let mut proc = Processor::new(&parsed); |
| 346 | +// dom_utils::scan_dom(&document, &mut |h| proc.visit(h)); |
| 347 | +// let result = proc.apply(); |
| 348 | +// let err = result.unwrap_err(); |
| 349 | +// assert!(err.to_string().contains("Line 2: ")); |
| 350 | +// } |
346 | 351 |
|
347 | 352 | #[tokio::test] |
348 | 353 | async fn test_var_inside_algorithm_ok() { |
|
0 commit comments