Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions plugins/prefixIds.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,20 @@ export const fn = (_root, params, info) => {
node.attributes[name] != null &&
node.attributes[name].length !== 0
) {
const parts = node.attributes[name].split(/\s*;\s+/).map((val) => {
if (val.endsWith('.end') || val.endsWith('.start')) {
const [id, postfix] = val.split('.');
return `${prefixId(prefixGenerator, id)}.${postfix}`;
// Semicolon-separated SMIL timing values don't require
// whitespace after the semicolon (e.g. "0;b.end-0.5s" is valid),
// so whitespace on either side must be optional here, not
// required after.
const parts = node.attributes[name].split(/\s*;\s*/).map((val) => {
// A syncbase-value is "id.begin" or "id.end", optionally
// followed by a "+"/"-" clock-value offset (e.g. "b.end-0.5s",
// "a.begin+0.1s") -- a plain suffix check misses any value
// with an offset, since it doesn't end with just ".begin" or
// ".end" anymore.
const match = /^([^.]+)\.(begin|end)([+-].+)?$/.exec(val);
if (match) {
const [, id, postfix, offset = ''] = match;
return `${prefixId(prefixGenerator, id)}.${postfix}${offset}`;
}
return val;
});
Expand Down
30 changes: 30 additions & 0 deletions test/plugins/prefixIds.14.svg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Prefix IDs should prefix begin/end syncbase references that carry a clock-value
offset (e.g. "b.end-0.5s"), not just a bare "id.begin"/"id.end" -- and should
split semicolon-separated values without requiring whitespace after the
semicolon.

===

<svg xmlns="http://www.w3.org/2000/svg">
<circle>
<animate id="a" attributeName="r" begin="0;b.end-0.5s" dur="1s" values="0;10;0"/>
</circle>
<circle>
<animate id="b" attributeName="r" begin="a.begin+0.1s" dur="1s" values="0;10;0"/>
</circle>
</svg>

@@@

<svg xmlns="http://www.w3.org/2000/svg">
<circle>
<animate id="icon-a" attributeName="r" begin="0; icon-b.end-0.5s" dur="1s" values="0;10;0"/>
</circle>
<circle>
<animate id="icon-b" attributeName="r" begin="icon-a.begin+0.1s" dur="1s" values="0;10;0"/>
</circle>
</svg>

@@@

{"prefix": "icon", "delim": "-"}