From 11e9e46c039b7df7a5e6c802b120cbeb04aa6164 Mon Sep 17 00:00:00 2001 From: Wim Rijnders Date: Tue, 18 Jul 2017 05:31:43 +0200 Subject: [PATCH] Allow DOM elements for node titles **Note: ** This is a simple fix and should be easy to review. Fix for #2579 - Adjusted node title definition in `options.js` to allow DOM elements - Changed `BridgeObject()` in `util.js` so that DOM elements are *not* bridged. --- lib/network/options.js | 2 +- lib/util.js | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/network/options.js b/lib/network/options.js index 66f123ca6..3db878dde 100644 --- a/lib/network/options.js +++ b/lib/network/options.js @@ -329,7 +329,7 @@ let allOptions = { __type__: { object } }, size: { number }, - title: { string, 'undefined': 'undefined' }, + title: { string, dom, 'undefined': 'undefined' }, value: { number, 'undefined': 'undefined' }, widthConstraint: { minimum: { number }, diff --git a/lib/util.js b/lib/util.js index 426fc854f..8f2a75b9a 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1238,10 +1238,16 @@ exports.selectiveBridgeObject = function (fields, referenceObject) { exports.bridgeObject = function (referenceObject) { if (typeof referenceObject == "object") { var objectTo = Object.create(referenceObject); - for (var i in referenceObject) { - if (referenceObject.hasOwnProperty(i)) { - if (typeof referenceObject[i] == "object") { - objectTo[i] = exports.bridgeObject(referenceObject[i]); + if (referenceObject instanceof Element) { + // Avoid bridging DOM objects + objectTo = referenceObject; + } else { + objectTo = Object.create(referenceObject); + for (var i in referenceObject) { + if (referenceObject.hasOwnProperty(i)) { + if (typeof referenceObject[i] == "object") { + objectTo[i] = exports.bridgeObject(referenceObject[i]); + } } } }