Don't overwrite the element's id if it has one already

This commit is contained in:
Joe DF 2022-05-29 21:30:48 -04:00
parent 4a877d60f7
commit 9772901d71

View File

@ -32,6 +32,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
const { option } = require("grunt");
(function( $ ){ (function( $ ){
/** /**
@ -60,9 +62,15 @@ $.Navigator = function( options ){
if ( options.element ) { if ( options.element ) {
if ( options.id ){ if ( options.id ){
$.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."); $.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead.");
} else {
// Don't overwrite the element's id if it has one already
if ( option.element.id ) {
options.id = option.element.id;
} else {
options.id = 'navigator-' + $.now();
}
} }
options.id = 'navigator-' + $.now();
this.element = options.element; this.element = options.element;
} else { } else {
this.element = document.getElementById( options.id ); this.element = document.getElementById( options.id );