Commit 2c074007 authored by campaign's avatar campaign

修复ie下range的报错

parent 181512d2
...@@ -3,6 +3,9 @@ Minder.Range = kity.createClass('Range',{ ...@@ -3,6 +3,9 @@ Minder.Range = kity.createClass('Range',{
this.nativeRange = document.createRange(); this.nativeRange = document.createRange();
this.nativeSel = window.getSelection(); this.nativeSel = window.getSelection();
}, },
hasNativeRange : function(){
return this.nativeSel.rangeCount != 0 ;
},
select:function(){ select:function(){
var start = this.nativeRange.startContainer; var start = this.nativeRange.startContainer;
if(start.nodeType == 1 && start.childNodes.length == 0){ if(start.nodeType == 1 && start.childNodes.length == 0){
......
...@@ -83,6 +83,9 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -83,6 +83,9 @@ Minder.Receiver = kity.createClass( 'Receiver', {
var keys = KityMinder.keymap; var keys = KityMinder.keymap;
function setTextToContainer() { function setTextToContainer() {
if(!me.range.hasNativeRange()){
return;
}
var text = me.container.textContent.replace( /[\u200b\t\r\n]/g, '' ); var text = me.container.textContent.replace( /[\u200b\t\r\n]/g, '' );
if ( me.textShape.getOpacity() == 0 ) { if ( me.textShape.getOpacity() == 0 ) {
...@@ -176,7 +179,6 @@ Minder.Receiver = kity.createClass( 'Receiver', { ...@@ -176,7 +179,6 @@ Minder.Receiver = kity.createClass( 'Receiver', {
break; break;
case 'beforekeyup': case 'beforekeyup':
switch ( keyCode ) { switch ( keyCode ) {
case keymap.Enter: case keymap.Enter:
case keymap.Tab: case keymap.Tab:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment