From 611f21665978ac54a0e7300de8f58db40dba03b7 Mon Sep 17 00:00:00 2001 From: Damien Whaley Date: Wed, 20 Nov 2013 11:46:54 +1100 Subject: [PATCH] Fix for IE not understanding commands with parameters I found that IE does not understand commands with parameters (such as "fontSize 3"). This fix strips off any parameters and also does a check to make sure the browser supports the command before it tries to query the state of the command. This is a little more generic than some of the other issue solutions which were only looking at fixing specific command problems. --- bootstrap-wysiwyg.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bootstrap-wysiwyg.js b/bootstrap-wysiwyg.js index 69f64a7..9b94eeb 100644 --- a/bootstrap-wysiwyg.js +++ b/bootstrap-wysiwyg.js @@ -26,11 +26,13 @@ updateToolbar = function () { if (options.activeToolbarClass) { $(options.toolbarSelector).find(toolbarBtnSelector).each(function () { - var command = $(this).data(options.commandRole); - if (document.queryCommandState(command)) { - $(this).addClass(options.activeToolbarClass); - } else { - $(this).removeClass(options.activeToolbarClass); + var command = $(this).data(options.commandRole).split(' ')[0]; + if (document.queryCommandSupported(command)) { + if (document.queryCommandState(command)) { + $(this).addClass(options.activeToolbarClass); + } else { + $(this).removeClass(options.activeToolbarClass); + } } }); }