From 761ceee2a5d7cd26d2a7b5db3c7be345ca6a0bae Mon Sep 17 00:00:00 2001 From: "Martin@MBP" Date: Fri, 27 Jan 2017 22:50:28 +0100 Subject: [PATCH] Fix `setEntry(title)` for titles containing icons Close #109 --- CHANGELOG.md | 4 ++-- jquery.ui-contextmenu.js | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4667234..dbd4cad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -# 1.13.0-0 / Unreleased - * +# 1.13.1-0 / Unreleased + * [BUGFIX] #109 Fix `setEntry(title)` for titles containing icons # 1.13.0 / 2016-08-21 diff --git a/jquery.ui-contextmenu.js b/jquery.ui-contextmenu.js index 2c1ecac..3944eff 100644 --- a/jquery.ui-contextmenu.js +++ b/jquery.ui-contextmenu.js @@ -476,13 +476,14 @@ $.extend($.moogle.contextmenu, { return item.has(">div[aria-haspopup='true']").length > 0; } }, - /** Replaces the value of elem's first text node child */ - replaceFirstTextNodeChild: function(elem, text) { + /** Replace the title of elem', but retain icons andchild entries. */ + replaceFirstTextNodeChild: function(elem, html) { + var $icons = elem.find(">span.ui-icon,>ul.ui-menu").detach(); + elem - .contents() - .filter(function() { return this.nodeType === 3; }) - .first() - .replaceWith(text); + .empty() + .html(html) + .append($icons); }, /** Updates the menu item's title */ updateTitle: function(item, title) {