From 5bd0ab090d3bb80742de5e0d7fc5a0d1e2b47c45 Mon Sep 17 00:00:00 2001 From: wimrijnders Date: Thu, 20 Jul 2017 21:31:39 +0200 Subject: [PATCH] Allow DOM elements for node titles (#3267) **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 bce74e978..db1069c7e 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]); + } } } }