Replace \ with \\

I was using a regular expression with ParsleyJS and had the HTML:

    <input type="text" pattern="^\d+$" />

I would receive an exception because the `\` was not escaped.  I added `.replace(/\\/g, '\\\\')` to the replace chain on line 50.  This escapes any `\` to `\\`.  It needs to go before escaping `"`, so we do not end up with `\\"` (which evaluates to `\"` instead of `"`).