MCPcopy Create free account
hub / github.com/Stranger6667/css-inline / append_rule

Function append_rule

css-inline/src/lib.rs:308–337  ·  view source on GitHub ↗
(
    buffer: &mut String,
    remainder: &RuleRemainder<'i>,
    declarations: &[parser::Declaration<'i>],
)

Source from the content-addressed store, hash-verified

306}
307
308fn append_rule<'i>(
309 buffer: &mut String,
310 remainder: &RuleRemainder<'i>,
311 declarations: &[parser::Declaration<'i>],
312) {
313 let (start, end) = remainder.declarations;
314 if start >= end || end > declarations.len() {
315 return;
316 }
317 let mut selectors_iter = remainder.selectors.iter().peekable();
318 while let Some(selector) = selectors_iter.next() {
319 buffer.push_str(selector);
320 if selectors_iter.peek().is_some() {
321 buffer.push_str(", ");
322 }
323 }
324 buffer.push_str(" {");
325 for (name, value) in &declarations[start..end] {
326 buffer.push(' ');
327 buffer.push_str(name);
328 buffer.push(':');
329 buffer.push(' ');
330 let value_trimmed = value.trim();
331 buffer.push_str(value_trimmed);
332 if !value_trimmed.ends_with(';') {
333 buffer.push(';');
334 }
335 }
336 buffer.push_str(" }\n");
337}
338
339fn overwrite_style_node(document: &mut Document, node_id: NodeId, new_css: &str) {
340 let new_css = new_css.trim();

Callers 1

rewrite_style_blocksFunction · 0.85

Calls 3

iterMethod · 0.80
nextMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected