Skip to content

Commit 55ed0ff

Browse files
render placeholder text
1 parent 7da4326 commit 55ed0ff

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/Parse.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,11 @@ _html2canvas.Parse = function (images, options) {
493493
valueWrap.style.top = bounds.top + "px";
494494
valueWrap.style.left = bounds.left + "px";
495495

496-
textValue = (el.nodeName === "SELECT") ? el.options[el.selectedIndex].text : el.value;
496+
textValue = (el.nodeName === "SELECT") ? (el.options[el.selectedIndex] || 0).text : el.value;
497+
if(!textValue) {
498+
textValue = el.placeholder;
499+
}
500+
497501
textNode = doc.createTextNode(textValue);
498502

499503
valueWrap.appendChild(textNode);
@@ -754,17 +758,17 @@ _html2canvas.Parse = function (images, options) {
754758
case "INPUT":
755759
// TODO add all relevant type's, i.e. HTML5 new stuff
756760
// todo add support for placeholder attribute for browsers which support it
757-
if (/^(text|url|email|submit|button|reset)$/.test(element.type) && element.value.length > 0){
761+
if (/^(text|url|email|submit|button|reset)$/.test(element.type) && (element.value || element.placeholder).length > 0){
758762
renderFormValue(element, bounds, stack);
759763
}
760764
break;
761765
case "TEXTAREA":
762-
if (element.value.length > 0){
766+
if ((element.value || element.placeholder).length > 0){
763767
renderFormValue(element, bounds, stack);
764768
}
765769
break;
766770
case "SELECT":
767-
if (element.options.length > 0){
771+
if ((element.options||element.placeholder).length > 0){
768772
renderFormValue(element, bounds, stack);
769773
}
770774
break;

0 commit comments

Comments
 (0)