From 0600312afd5ef43c55bc9b8fa560ea7702aa3ebf Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Sun, 8 Nov 2015 20:27:07 -0800 Subject: [PATCH] Release v1.0.5 --- bower.json | 2 +- dist/select.js | 5 +++-- package.json | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index a0a21a9..6c5c675 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "select", - "version": "1.0.4", + "version": "1.0.5", "description": "Programmatically select the text of a HTML element", "license": "MIT", "main": "dist/select.js", diff --git a/dist/select.js b/dist/select.js index 2a36117..d94879f 100644 --- a/dist/select.js +++ b/dist/select.js @@ -3,7 +3,7 @@ function select(element) { var selectedText; if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { - element.select(); + element.setSelectionRange(0, element.value.length); selectedText = element.value; } @@ -14,11 +14,12 @@ function select(element) { range.selectNodeContents(element); selection.removeAllRanges(); selection.addRange(range); - element.focus(); selectedText = selection.toString(); } + element.focus(); + return selectedText; } diff --git a/package.json b/package.json index 7b4f794..df789ce 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "select", "description": "Programmatically select the text of a HTML element", - "version": "1.0.4", + "version": "1.0.5", "main": "src/select.js", "repository": "zenorocha/select", "keywords": [