-
Notifications
You must be signed in to change notification settings - Fork 59
Fix: idPrefix regex to support style attribute #90
base: master
Are you sure you want to change the base?
Conversation
lib/transformer.js
Outdated
@@ -131,7 +131,7 @@ function createClassPrefix(classPrefix) { | |||
} | |||
|
|||
function createIdPrefix(idPrefix) { | |||
var url_pattern = /^url\(#.+\)$/i; | |||
var url_pattern = /url\(#.+?\)/i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why add the question mark here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mathroc to enable lazy mode.
In greedy mode, the following
<g style="mask: url(#foo); color: rgba(0, 0, 0, 0, .1)">
would match
url(#foo); color: rgba(0, 0, 0, 0, .1)
but we want
url(#foo)
Currently createIdPrefix for tag attributes only works if the url is the first value. e.g: <path mask="url(#foo")> This commit adds support also for the following. <g style="mask: url(#foo)">
@@ -131,7 +131,7 @@ function createClassPrefix(classPrefix) { | |||
} | |||
|
|||
function createIdPrefix(idPrefix) { | |||
var url_pattern = /^url\(#.+\)$/i; | |||
var url_pattern = /url\(#.+?\)/gi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it wont work for this
<path mask="url(#foo")>
I guess keeping both can be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anikethsaha It passes the tests though.
why wouldn't it work?
Currently createIdPrefix for tag attributes only works if the
url(#foo)
is the only value.e.g:
This commit adds support for the following.