From 9772901d719b173e1144732ff5bb61b95674e7ea Mon Sep 17 00:00:00 2001 From: Joe DF <3848219+joedf@users.noreply.github.com> Date: Sun, 29 May 2022 21:30:48 -0400 Subject: [PATCH] Don't overwrite the element's id if it has one already --- src/navigator.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/navigator.js b/src/navigator.js index 64f24b67..6ecddef0 100644 --- a/src/navigator.js +++ b/src/navigator.js @@ -32,6 +32,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +const { option } = require("grunt"); + (function( $ ){ /** @@ -60,9 +62,15 @@ $.Navigator = function( options ){ if ( options.element ) { if ( options.id ){ $.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; } else { this.element = document.getElementById( options.id );