mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
render placeholder text
This commit is contained in:
parent
7da4326885
commit
55ed0ffde0
12
src/Parse.js
12
src/Parse.js
@ -493,7 +493,11 @@ _html2canvas.Parse = function (images, options) {
|
|||||||
valueWrap.style.top = bounds.top + "px";
|
valueWrap.style.top = bounds.top + "px";
|
||||||
valueWrap.style.left = bounds.left + "px";
|
valueWrap.style.left = bounds.left + "px";
|
||||||
|
|
||||||
textValue = (el.nodeName === "SELECT") ? el.options[el.selectedIndex].text : el.value;
|
textValue = (el.nodeName === "SELECT") ? (el.options[el.selectedIndex] || 0).text : el.value;
|
||||||
|
if(!textValue) {
|
||||||
|
textValue = el.placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
textNode = doc.createTextNode(textValue);
|
textNode = doc.createTextNode(textValue);
|
||||||
|
|
||||||
valueWrap.appendChild(textNode);
|
valueWrap.appendChild(textNode);
|
||||||
@ -754,17 +758,17 @@ _html2canvas.Parse = function (images, options) {
|
|||||||
case "INPUT":
|
case "INPUT":
|
||||||
// TODO add all relevant type's, i.e. HTML5 new stuff
|
// TODO add all relevant type's, i.e. HTML5 new stuff
|
||||||
// todo add support for placeholder attribute for browsers which support it
|
// todo add support for placeholder attribute for browsers which support it
|
||||||
if (/^(text|url|email|submit|button|reset)$/.test(element.type) && element.value.length > 0){
|
if (/^(text|url|email|submit|button|reset)$/.test(element.type) && (element.value || element.placeholder).length > 0){
|
||||||
renderFormValue(element, bounds, stack);
|
renderFormValue(element, bounds, stack);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "TEXTAREA":
|
case "TEXTAREA":
|
||||||
if (element.value.length > 0){
|
if ((element.value || element.placeholder).length > 0){
|
||||||
renderFormValue(element, bounds, stack);
|
renderFormValue(element, bounds, stack);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "SELECT":
|
case "SELECT":
|
||||||
if (element.options.length > 0){
|
if ((element.options||element.placeholder).length > 0){
|
||||||
renderFormValue(element, bounds, stack);
|
renderFormValue(element, bounds, stack);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user