question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove baskslash in pattern attribute

See original GitHub issue

Hi,

It seems that the plugin remove backslash in pattern attributes when inlining the template.

Before :

<input type="text" [(ngModel)]="search.imei" id="form-imei" class="form-control" pattern="\d+" required />

After :

<input type="text" [(ngModel)]="search.imei" id="form-imei" class="form-control" pattern="d+" required />

Thanks in advance

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dougellisoncommented, Oct 1, 2016

This still appears to be an issue. I’ve recently updated from Angular2 RC5 to Final and accomplished that by merging the latest seed changes. My lazy solution has been to run with pattern with a single \ in dev but when I’m happy with its functionality I go through and replace with \ -> \ and then it works fine in production.

0reactions
gregjacobscommented, Nov 5, 2016

It seems like this is a general issue @ludohenin where backslashes in html/css files need to be escaped for when they are placed into string literals in JavaScript.

JavaScript would interpret the string literal "\d" in code to simply be the string d.

We basically need to convert this html:

<input pattern="\d+">

To the following JavaScript:

@Component({
    template: `<input pattern="\\d+">`
})

Which will ultimately form this string in memory: <input pattern="\d+">

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing backslashes from strings in javascript
Try str = str.replace(/\\/g, '');.
Read more >
How to remove a text followed by backslash in file using sed ...
This will act on lines which contain the <base pattern, and replace the pattern href="/any text up to the double quote with href="/...
Read more >
Learning About Regular Expressions - L3HarrisGeospatial.com
The backslash suppresses the special meaning of the character it precedes, and turns it into an ordinary character. To insert a backslash into...
Read more >
Regex support for pattern attribute · Issue #132 - GitHub
Current behavior: I use angularjs, and some inputs has ng-pattern attribute. html-loader remove backslashes in regex inside this attribute and ...
Read more >
HTML attribute: pattern - HTML: HyperText Markup Language
The pattern attribute specifies a regular expression the form control's ... No forward slashes should be specified around the pattern text.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found