Skip to content

Commit

Permalink
Allow DOM elements for node titles (almende#3267)
Browse files Browse the repository at this point in the history
**Note: ** This is a simple fix and should be easy to review.

Fix for almende#2579

- Adjusted node title definition in `options.js` to allow DOM elements
- Changed `BridgeObject()` in `util.js` so that DOM elements are *not* bridged.
  • Loading branch information
wimrijnders authored and Primoz Susa committed Jan 3, 2019
1 parent bd66218 commit 5bd0ab0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/network/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
14 changes: 10 additions & 4 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
}
}
Expand Down

0 comments on commit 5bd0ab0

Please sign in to comment.