You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fn main() {
let js_str = r#"export const IconText = {
extend: 'Flex',
type: 'checkbox',
':checked + div': 'primary',
display: 'none',
};"#;
let js_code_bytes = js_str.as_bytes();
let source = Source::from_bytes(js_code_bytes);
let mut parser = parser::Parser::new(source);
let mut interner = Interner::new();
let tree = parser.parse_module(&mut interner);
let output = match tree {
Ok(root) => {
let module_item_list: &boa_ast::ModuleItemList = module.items();
let items: &[ModuleItem] = module_item_list.items();
let item_0 = items[0].clone();
if let ModuleItem::ExportDeclaration(e) = item_0 {
if let ExportDeclaration::Declaration(d) = e {
let interned_string = d.to_interned_string(interner);
dbg!(interned_string);
}
}
},
Err(e) => panic!(),
};
}
And after printing out the javascript code using d.to_interned_string(interner);, we see this result:
And most importantly, notice that \n :checked + div: no longer has the quotes that were in the input. But as you can see, the rest of the values in the object still have their quotes - just not this key.
The text was updated successfully, but these errors were encountered:
Hmm, this is a bit complex. We don't store the quotes on string properties because they're not needed on the AST itself, so we save a bit of memory doing this.
What I can think of is that this'll probably be resolved if we start implementing the AST spans, which will allow to reference the original lines of code (including quotes) when printing the AST as code.
See this example javascript code:
and notice the
':checked + div'
field.After parsing this code, like so:
And after printing out the javascript code using
d.to_interned_string(interner);
, we see this result:And most importantly, notice that
\n :checked + div:
no longer has the quotes that were in the input. But as you can see, the rest of the values in the object still have their quotes - just not this key.The text was updated successfully, but these errors were encountered: