This is an automated email from the ASF dual-hosted git repository. niklasmerz pushed a commit to branch plugin-search in repository https://gitbox.apache.org/repos/asf/cordova-docs.git
commit 9c4e583a01de0b89c111ca09fbbc03a5e44f4fb7 Author: Niklas Merz <niklasm...@apache.org> AuthorDate: Sat Jan 18 11:44:10 2020 +0100 Fix "Argument 1 of Range.selectNode is not an object" --- www/static/plugins/plugin.jsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/www/static/plugins/plugin.jsx b/www/static/plugins/plugin.jsx index b63dce5..3886a26 100755 --- a/www/static/plugins/plugin.jsx +++ b/www/static/plugins/plugin.jsx @@ -10,19 +10,22 @@ var Plugin = createClass({ }, copyText: function() { var range = document.createRange(); - range.selectNode(this.getDOMNode().getElementsByClassName("cordova-add-command")[0]); + var elements = this.getDOMNode().getElementsByClassName("cordova-add-command"); + if(elements.length > 0) { + range.selectNode(elements[0]); - var select = window.getSelection(); - select.removeAllRanges(); - select.addRange(range); + var select = window.getSelection(); + select.removeAllRanges(); + select.addRange(range); - try { - document.execCommand("copy"); - } catch(e) { - // Silently fail for now - } + try { + document.execCommand("copy"); + } catch(e) { + // Silently fail for now + } - select.removeAllRanges(); + select.removeAllRanges(); + } }, render: function() { if(!this.props.plugin) { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org For additional commands, e-mail: commits-h...@cordova.apache.org