Fix problem with IE11

It turns out that IE11 has a horrible bug whereby setting the
placeholder attribute before setting the text will trigger an input
event:

https://social.msdn.microsoft.com/Forums/ie/en-US/ae4832b0-8eee-4729-b93
3-a9977ea1b583/internet-explorer-input-event-get-fired-when-settingunset
ting-the-placeholder?forum=iewebdevelopment
print-window-tiddler
Jermolene 2016-05-01 18:17:28 +01:00
rodzic 037cfb7cc7
commit 01eb45946c
2 zmienionych plików z 14 dodań i 12 usunięć

Wyświetl plik

@ -51,6 +51,13 @@ function FramedEngine(options) {
tag = "input"; tag = "input";
} }
this.domNode = this.iframeDoc.createElement(tag); this.domNode = this.iframeDoc.createElement(tag);
// Set the text
if(this.widget.editTag === "textarea") {
this.domNode.appendChild(this.iframeDoc.createTextNode(this.value));
} else {
this.domNode.value = this.value;
}
// Set the attributes
if(this.widget.editType) { if(this.widget.editType) {
this.domNode.setAttribute("type",this.widget.editType); this.domNode.setAttribute("type",this.widget.editType);
} }
@ -65,12 +72,6 @@ function FramedEngine(options) {
} }
// Copy the styles from the dummy textarea // Copy the styles from the dummy textarea
this.copyStyles(); this.copyStyles();
// Set the text
if(this.widget.editTag === "textarea") {
this.domNode.appendChild(this.iframeDoc.createTextNode(this.value));
} else {
this.domNode.value = this.value;
}
// Add event listeners // Add event listeners
$tw.utils.addEventListeners(this.domNode,[ $tw.utils.addEventListeners(this.domNode,[
{name: "input",handlerObject: this,handlerMethod: "handleInputEvent"}, {name: "input",handlerObject: this,handlerMethod: "handleInputEvent"},

Wyświetl plik

@ -27,6 +27,13 @@ function SimpleEngine(options) {
tag = "input"; tag = "input";
} }
this.domNode = this.widget.document.createElement(tag); this.domNode = this.widget.document.createElement(tag);
// Set the text
if(this.widget.editTag === "textarea") {
this.domNode.appendChild(this.widget.document.createTextNode(this.value));
} else {
this.domNode.value = this.value;
}
// Set the attributes
if(this.widget.editType) { if(this.widget.editType) {
this.domNode.setAttribute("type",this.widget.editType); this.domNode.setAttribute("type",this.widget.editType);
} }
@ -42,12 +49,6 @@ function SimpleEngine(options) {
if(this.widget.editClass) { if(this.widget.editClass) {
this.domNode.className = this.widget.editClass; this.domNode.className = this.widget.editClass;
} }
// Set the text
if(this.widget.editTag === "textarea") {
this.domNode.appendChild(this.widget.document.createTextNode(this.value));
} else {
this.domNode.value = this.value;
}
// Add an input event handler // Add an input event handler
$tw.utils.addEventListeners(this.domNode,[ $tw.utils.addEventListeners(this.domNode,[
{name: "focus", handlerObject: this, handlerMethod: "handleFocusEvent"}, {name: "focus", handlerObject: this, handlerMethod: "handleFocusEvent"},