Skip to content

Commit

Permalink
Update the implementation so that it matches the ember-source version
Browse files Browse the repository at this point in the history
Ember has recently implemented this feature so we can match the polyfill
implementation with that version.

emberjs/ember.js#19882
  • Loading branch information
Windvis authored and ctjhoa committed Mar 2, 2022
1 parent ed861e8 commit a4840a6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions addon/helpers/unique-id.js
@@ -1,6 +1,10 @@
import { helper } from '@ember/component/helper';
import { guidFor } from '@ember/object/internals';

export default helper(function uniqueId() {
return guidFor({});
});
export default helper(uniqueId);

// Copy-pasted from the ember-source implementation: https://github.com/emberjs/ember.js/pull/19882
function uniqueId() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (a) =>
(a ^ ((Math.random() * 16) >> (a / 4))).toString(16)
);
}

0 comments on commit a4840a6

Please sign in to comment.