iron-demo-helpers icon indicating copy to clipboard operation
iron-demo-helpers copied to clipboard

Display attributes with double quotes inside using single quotes

Open tommie opened this issue 8 years ago • 4 comments

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.

tommie avatar Feb 25 '16 13:02 tommie

Any plans to implement this fix?

eugef avatar Nov 11 '16 12:11 eugef

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 :)

notwaldorf avatar Apr 17 '17 22:04 notwaldorf

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.

csonnhalter avatar Aug 25 '17 16:08 csonnhalter

+1 From: https://www.polymer-project.org/2.0/docs/devguide/properties#configuring-object-and-array-properties image

Result: image

super-kamil avatar Feb 13 '18 14:02 super-kamil