locize
Version:
This package adds the incontext editor to your i18next setup.
50 lines (42 loc) • 1.62 kB
JavaScript
/* eslint-disable */
/**
* @file Returns the unique identifier generated by the browser for the object.
* The uniqueID property of the document works as an identifier generator in Internet Explorer.
* Each time when the value of this uniqueID property is retrieved, the browser generates
* a new unique identifier and returns it.
* HTML elements also support the uniqueID property. The first time when the value of any of these
* properties is retrieved, the browser generates a new identifier for the element.
* @author Renaat De Muynck <renaat.demuynck@gmail.com>
*/
;(function () {
'use strict'
if (typeof Document === 'undefined') return
var nextID = 1
if (Document.prototype.hasOwnProperty('uniqueID')) {
return
}
console.info('"document.uniqueID" not implemented; creating shim')
// define a property on the document that will generate a unique id each time it is called
Object.defineProperty(Document.prototype, 'uniqueID', {
get: function () {
return nextID++
},
enumerable: false,
configurable: false
})
// define a property on the element that will return a unique id the first time it is called
Object.defineProperty(Element.prototype, 'uniqueID', {
get: function () {
// redefine the property so that the generator will not be called again
Object.defineProperty(this, 'uniqueID', {
value: document.uniqueID,
writable: false,
enumerable: false,
configurable: false
})
return this.uniqueID
},
enumerable: false,
configurable: true
})
})()