@@ -4469,13 +4469,17 @@ abstract class ModelElement extends Canonicalization
44694469 // Matches valid javascript identifiers.
44704470 final RegExp validIdRegExp = RegExp (r'^[a-zA-Z_]\w*$' );
44714471
4472- final Set <String > uniqueIds = Set <String >();
4472+ // Make sure we have a set to keep track of used IDs for this href.
4473+ package.usedAnimationIdsByHref[href] ?? = {};
4474+
44734475 String getUniqueId (String base ) {
4474- int count = 1 ;
4475- String id = '$base $count ' ;
4476- while (uniqueIds.contains (id)) {
4477- count++ ;
4478- id = '$base $count ' ;
4476+ int animationIdCount = 1 ;
4477+ String id = '$base $animationIdCount ' ;
4478+ // We check for duplicate IDs so that we make sure not to collide with
4479+ // user-supplied ids on the same page.
4480+ while (package.usedAnimationIdsByHref[href].contains (id)) {
4481+ animationIdCount++ ;
4482+ id = '$base $animationIdCount ' ;
44794483 }
44804484 return id;
44814485 }
@@ -4513,13 +4517,13 @@ abstract class ModelElement extends Canonicalization
45134517 'and must not begin with a number.' );
45144518 return '' ;
45154519 }
4516- if (uniqueIds .contains (uniqueId)) {
4520+ if (package.usedAnimationIdsByHref[href] .contains (uniqueId)) {
45174521 warn (PackageWarning .invalidParameter,
45184522 message: 'An animation has a non-unique identifier, "$uniqueId ". '
45194523 'Animation identifiers must be unique.' );
45204524 return '' ;
45214525 }
4522- uniqueIds .add (uniqueId);
4526+ package.usedAnimationIdsByHref[href] .add (uniqueId);
45234527
45244528 int width;
45254529 try {
@@ -4569,7 +4573,8 @@ abstract class ModelElement extends Canonicalization
45694573
45704574<div style="position: relative;">
45714575 <div id="${overlayId }"
4572- onclick="if ($uniqueId .paused) {
4576+ onclick="var $uniqueId = document.getElementById('$uniqueId ');
4577+ if ($uniqueId .paused) {
45734578 $uniqueId .play();
45744579 this.style.display = 'none';
45754580 } else {
@@ -4586,7 +4591,8 @@ abstract class ModelElement extends Canonicalization
45864591 </div>
45874592 <video id="$uniqueId "
45884593 style="width:${width }px; height:${height }px;"
4589- onclick="if (this.paused) {
4594+ onclick="var $overlayId = document.getElementById('$overlayId ');
4595+ if (this.paused) {
45904596 this.play();
45914597 $overlayId .style.display = 'none';
45924598 } else {
@@ -6308,6 +6314,10 @@ class Package extends LibraryContainer
63086314 /// Number of times we have invoked a tool for this package.
63096315 int toolInvocationIndex = 0 ;
63106316
6317+ // The animation IDs that have already been used, indexed by the [href] of the
6318+ // object that contains them.
6319+ Map <String , Set <String >> usedAnimationIdsByHref = {};
6320+
63116321 /// Pieces of the location split by [locationSplitter] (removing package: and
63126322 /// slashes).
63136323 @override
0 commit comments