-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow . and # replacements and allow class name and id replacement
- Loading branch information
Showing
2 changed files
with
26 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
const matchValueName = /[$#]?[\w-\.]+/g | ||
const matchValueName = /[$]?[\w-]+[\w.]*/g; | ||
|
||
const replaceValueSymbols = (value, replacements) => { | ||
let matches | ||
let matches; | ||
while ((matches = matchValueName.exec(value))) { | ||
const replacement = replacements[matches[0]] | ||
const replacement = replacements[matches[0]]; | ||
if (replacement) { | ||
value = | ||
value.slice(0, matches.index) + | ||
replacement + | ||
value.slice(matchValueName.lastIndex) | ||
matchValueName.lastIndex -= matches[0].length - replacement.length | ||
value.slice(matchValueName.lastIndex); | ||
matchValueName.lastIndex -= matches[0].length - replacement.length; | ||
} | ||
} | ||
return value | ||
} | ||
return value; | ||
}; | ||
|
||
export default replaceValueSymbols | ||
export default replaceValueSymbols; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters