Mention attr with default value removal in README; add <style> default attr values

This commit is contained in:
Wilson Lin 2020-01-18 11:47:38 +11:00
parent 27af2368ff
commit b4f8a041b2
4 changed files with 10 additions and 8 deletions

View File

@ -299,10 +299,9 @@ Any entities in attribute values are decoded, and then the shortest representati
`class` attributes have their whitespace (after any decoding) trimmed and collapsed.
[Boolean attribute](./gen/boolean_attrs.json) values are removed.
[Some attributes](./gen/redundant_if_empty_attrs.json) are completely removed if their value is empty after any processing.
[Some attributes](./gen/redundant_if_empty_attrs.json) are completely removed if their value is empty or the default value after any processing.
`type` attributes on `script` tags with a value equaling a [JavaScript MIME type](https://mimesniff.spec.whatwg.org/#javascript-mime-type) are removed.
`type` attributes on `style` tags are removed.
If an attribute value is empty after any processing, everything but the name is completely removed (i.e. no `=`), as an empty attribute is implicitly [the same](https://html.spec.whatwg.org/multipage/syntax.html#attributes-2) as an attribute with an empty string value.

View File

@ -981,7 +981,8 @@
"style": {
"boolean": false,
"redundant_if_empty": true,
"collapse_and_trim": false
"collapse_and_trim": false,
"default_value": "all"
}
},
"mediagroup": {
@ -1675,7 +1676,8 @@
"style": {
"boolean": false,
"redundant_if_empty": true,
"collapse_and_trim": false
"collapse_and_trim": false,
"default_value": "text/css"
}
},
"typeof": {

View File

@ -71,6 +71,10 @@ const defaultAttributeValues = {
tags: ['iframe', 'img'],
defaultValue: 'eager',
}],
'media': [{
tags: ['style'],
defaultValue: 'all',
}],
'method': [{
tags: ['form'],
defaultValue: 'get',
@ -99,7 +103,7 @@ const defaultAttributeValues = {
tags: ['input'],
defaultValue: 'text',
}, {
tags: ['link'],
tags: ['link', 'style'],
defaultValue: 'text/css',
}],
'width': [{

View File

@ -135,9 +135,6 @@ pub fn process_tag(proc: &mut Processor, prev_sibling_closing_tag: Option<Proces
erase_attr = true;
};
}
(TagType::Style, b"type") => {
erase_attr = true;
}
(_, name) => {
// TODO Check if HTML tag before checking if attribute removal applies to all elements.
erase_attr = match (value, ATTRS.get(&proc[tag_name], name)) {