You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ni...@apache.org on 2020/01/18 10:44:33 UTC

[cordova-docs] branch plugin-search updated: Fix "Argument 1 of Range.selectNode is not an object"

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


The following commit(s) were added to refs/heads/plugin-search by this push:
     new 5cdf0d0  Fix "Argument 1 of Range.selectNode is not an object"
5cdf0d0 is described below

commit 5cdf0d0a4eb6e595bed764a8fd6233c9577becdb
Author: Niklas Merz <ni...@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-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org