iron-demo-helpers
iron-demo-helpers copied to clipboard
Display attributes with double quotes inside using single quotes
Object literals in the code snippets look better if they don't contain " escaping. E.g. using
// Attributes with embedded JSON look better with apostrophes.
snippet = snippet.replace(/="[^"]*"[^"]*"/g, function(s) {
// If there are apostrophes, be safe and don't fiddle with it.
if (s.indexOf("'") !== -1 || s.indexOf(''') !== -1)
return s;
return s.replace(/"/g, "'").replace(/"/g, '"');
});
This should not have more false-positives than the empty attribute removal already in place.
Any plans to implement this fix?
There's no PR for this at the moment. I would tend to prefer less magic in that regex, but if it came with a bunch of tests, I would review it :)
I think tommi's snippet works fine, I tested it on jsbin: https://jsbin.com/berezuc/edit?html,js,output. Nice looking object literals would be really helpful for me.
+1
From: https://www.polymer-project.org/2.0/docs/devguide/properties#configuring-object-and-array-properties
Result: