@@ -4452,13 +4452,17 @@ abstract class ModelElement extends Canonicalization
4452
4452
// Matches valid javascript identifiers.
4453
4453
final RegExp validIdRegExp = RegExp (r'^[a-zA-Z_]\w*$' );
4454
4454
4455
- final Set <String > uniqueIds = Set <String >();
4455
+ // Make sure we have a set to keep track of used IDs for this href.
4456
+ package.usedAnimationIdsByHref[href] ?? = {};
4457
+
4456
4458
String getUniqueId (String base ) {
4457
- int count = 1 ;
4458
- String id = '$base $count ' ;
4459
- while (uniqueIds.contains (id)) {
4460
- count++ ;
4461
- id = '$base $count ' ;
4459
+ int animationIdCount = 1 ;
4460
+ String id = '$base $animationIdCount ' ;
4461
+ // We check for duplicate IDs so that we make sure not to collide with
4462
+ // user-supplied ids on the same page.
4463
+ while (package.usedAnimationIdsByHref[href].contains (id)) {
4464
+ animationIdCount++ ;
4465
+ id = '$base $animationIdCount ' ;
4462
4466
}
4463
4467
return id;
4464
4468
}
@@ -4476,7 +4480,7 @@ abstract class ModelElement extends Canonicalization
4476
4480
bool wasDeprecated = false ;
4477
4481
if (positionalArgs.length == 4 ) {
4478
4482
// Supports the original form of the animation tag for backward
4479
- // compatibility.
4483
+ // compatibility.`
4480
4484
uniqueId = positionalArgs.removeAt (0 );
4481
4485
wasDeprecated = true ;
4482
4486
} else if (positionalArgs.length == 3 ) {
@@ -4496,13 +4500,13 @@ abstract class ModelElement extends Canonicalization
4496
4500
'and must not begin with a number.' );
4497
4501
return '' ;
4498
4502
}
4499
- if (uniqueIds .contains (uniqueId)) {
4503
+ if (package.usedAnimationIdsByHref[href] .contains (uniqueId)) {
4500
4504
warn (PackageWarning .invalidParameter,
4501
4505
message: 'An animation has a non-unique identifier, "$uniqueId ". '
4502
4506
'Animation identifiers must be unique.' );
4503
4507
return '' ;
4504
4508
}
4505
- uniqueIds .add (uniqueId);
4509
+ package.usedAnimationIdsByHref[href] .add (uniqueId);
4506
4510
4507
4511
int width;
4508
4512
try {
@@ -4552,7 +4556,8 @@ abstract class ModelElement extends Canonicalization
4552
4556
4553
4557
<div style="position: relative;">
4554
4558
<div id="${overlayId }"
4555
- onclick="if ($uniqueId .paused) {
4559
+ onclick="var $uniqueId = document.getElementById('$uniqueId ');
4560
+ if ($uniqueId .paused) {
4556
4561
$uniqueId .play();
4557
4562
this.style.display = 'none';
4558
4563
} else {
@@ -4569,7 +4574,8 @@ abstract class ModelElement extends Canonicalization
4569
4574
</div>
4570
4575
<video id="$uniqueId "
4571
4576
style="width:${width }px; height:${height }px;"
4572
- onclick="if (this.paused) {
4577
+ onclick="var $overlayId = document.getElementById('$overlayId ');
4578
+ if (this.paused) {
4573
4579
this.play();
4574
4580
$overlayId .style.display = 'none';
4575
4581
} else {
@@ -6294,6 +6300,10 @@ class Package extends LibraryContainer
6294
6300
/// Number of times we have invoked a tool for this package.
6295
6301
int toolInvocationIndex = 0 ;
6296
6302
6303
+ // The animation IDs that have already been used, indexed by the [href] of the
6304
+ // object that contains them.
6305
+ Map <String , Set <String >> usedAnimationIdsByHref = {};
6306
+
6297
6307
/// Pieces of the location split by [locationSplitter] (removing package: and
6298
6308
/// slashes).
6299
6309
@override
0 commit comments