mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix CSSStyleDeclaration's item() to provide properties instead of values (#31299)
For example, style.cssText = "margin: 1px 2px 3px 4px"; [...style]; will now be ["margin-top", "margin-right", "margin-bottom", "margin-left"] instead of ["1px", "2px", "3px", "4px"]
This commit is contained in:
parent
9d42602fe7
commit
f2adcc3a12
19 changed files with 8 additions and 149 deletions
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::CssStringWriter;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::local_name;
|
||||
use servo_arc::Arc;
|
||||
|
@ -14,7 +15,7 @@ use style::properties::{
|
|||
use style::selector_parser::PseudoElement;
|
||||
use style::shared_lock::Locked;
|
||||
use style::stylesheets::{CssRuleType, Origin};
|
||||
use style_traits::ParsingMode;
|
||||
use style_traits::{CssWriter, ParsingMode, ToCss};
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
|
@ -431,13 +432,11 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
|
|||
fn IndexedGetter(&self, index: u32) -> Option<DOMString> {
|
||||
self.owner.with_block(|pdb| {
|
||||
let declaration = pdb.declarations().get(index as usize)?;
|
||||
let important = pdb.declarations_importance().get(index as usize)?;
|
||||
let mut css = String::new();
|
||||
declaration.to_css(&mut css).unwrap();
|
||||
if important {
|
||||
css += " !important";
|
||||
}
|
||||
Some(DOMString::from(css))
|
||||
let mut dest = String::new();
|
||||
let mut writer = CssStringWriter::new(&mut dest);
|
||||
let mut writer = CssWriter::new(&mut writer);
|
||||
declaration.id().to_css(&mut writer).ok()?;
|
||||
Some(DOMString::from(dest))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue