Browse Source

firefox26 placeholderbug修改

zhouna 5 years atrás
parent
commit
001b244a13
1 changed files with 3 additions and 3 deletions
  1. 3 3
      src/common/components/InlineTag/index.jsx

+ 3 - 3
src/common/components/InlineTag/index.jsx

@@ -26,14 +26,14 @@ class InlineTag extends Component {
   }
   handleInput(e){       //输入时保存临时值,在修改灰显为黑色时判断用
     e.stopPropagation();
-    const value = e.target.innerText;
+    const value = e.target.innerText||e.target.innerHTML.replace(/ $|^ /,'');//兼容firefox26
     this.setState({
       value:value
     })
   }
   handleBlur(e){         //鼠标离开是保存值到store中
     e.stopPropagation(); //不阻止会触发外层div的失焦事件
-    const value = e.target.innerText;
+    const value = e.target.innerText||e.target.innerHTML.replace(/ $|^ /,'');;
     const {handleInput,ikey,prefix,suffix,placeholder} = this.props;
     if(!value.trim()){
       this.setState({
@@ -49,7 +49,7 @@ class InlineTag extends Component {
   }
   handleFocus(e){
     e.stopPropagation();
-    const text = e.target.innerText || e.target.innerHTML;
+    const text = e.target.innerText || e.target.innerHTML.replace(/ $|^ /,'');;
     const {placeholder} = this.props;
     if(text.trim()==placeholder){
       this.setState({