Skip to content

Commit

Permalink
Merge pull request #3007 from scmsystm/master
Browse files Browse the repository at this point in the history
refactor(tap): use cloneNode() to clone focused input
  • Loading branch information
adamdbradley committed Feb 11, 2015
2 parents 2885258 + be0e4af commit 64786fb
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions js/utils/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,24 +188,19 @@ ionic.tap = {
ionic.requestAnimationFrame(function() {
var focusInput = container.querySelector(':focus');
if (ionic.tap.isTextInput(focusInput)) {
var clonedInput = focusInput.parentElement.querySelector('.cloned-text-input');
if (!clonedInput) {
clonedInput = document.createElement(focusInput.tagName);
clonedInput.placeholder = focusInput.placeholder;
clonedInput.type = focusInput.type;
clonedInput.value = focusInput.value;
clonedInput.style = focusInput.style;
clonedInput.className = focusInput.className;
clonedInput.classList.add('cloned-text-input');
clonedInput.readOnly = true;
if (focusInput.isContentEditable) {
clonedInput.contentEditable = focusInput.contentEditable;
clonedInput.innerHTML = focusInput.innerHTML;
}
focusInput.parentElement.insertBefore(clonedInput, focusInput);
focusInput.style.top = focusInput.offsetTop;
focusInput.classList.add('previous-input-focus');
var clonedInput = focusInput.cloneNode(true);

clonedInput.value = focusInput.value;
clonedInput.classList.add('cloned-text-input');
clonedInput.readOnly = true;
if (focusInput.isContentEditable) {
clonedInput.contentEditable = focusInput.contentEditable;
clonedInput.innerHTML = focusInput.innerHTML;
}
focusInput.parentElement.insertBefore(clonedInput, focusInput);
focusInput.classList.add('previous-input-focus');

clonedInput.scrollTop = focusInput.scrollTop;
}
});
},
Expand Down

0 comments on commit 64786fb

Please sign in to comment.