From 641d6d24af0b42ebcc999e6623cd97c24b407c91 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 10 Jan 2017 15:52:09 +0100 Subject: [PATCH] kivi.detect_duplicate_ids_in_dom: Funktion zum Auffinden doppelter IDs im DOM --- js/kivi.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/kivi.js b/js/kivi.js index c456bd71d..17384220c 100644 --- a/js/kivi.js +++ b/js/kivi.js @@ -415,6 +415,22 @@ namespace("kivi", function(ns) { console.error('kivi.run("' + function_name + '"): No function by that name found'); return undefined; }; + + ns.detect_duplicate_ids_in_dom = function() { + var ids = {}, + found = false; + + $('[id]').each(function() { + if (this.id && ids[this.id]) { + found = true; + console.warn('Duplicate ID #' + this.id); + } + ids[this.id] = 1; + }); + + if (!found) + console.log('No duplicate IDs found :)'); + }; }); kivi = namespace('kivi'); -- 2.20.1