mirror of
https://github.com/danog/dart-sass.git
synced 2024-12-02 09:37:49 +01:00
Ensure uniqueness for unique-id().
This commit is contained in:
parent
61dfecc697
commit
9e03630b3c
@ -878,7 +878,7 @@ void defineCoreFunctions(Environment environment) {
|
||||
|
||||
environment.defineFunction("unique-id", "", (arguments) {
|
||||
// Make it difficult to guess the next ID by randomizing the increase.
|
||||
_uniqueID += _random.nextInt(36);
|
||||
_uniqueID += _random.nextInt(36) + 1;
|
||||
if (_uniqueID > math.pow(36, 6)) _uniqueID %= math.pow(36, 6);
|
||||
// The leading "u" ensures that the result is a valid identifier.
|
||||
return new SassString("u${_uniqueID.toRadixString(36).padLeft(6, '0')}");
|
||||
|
Loading…
Reference in New Issue
Block a user