Index: trunk/extensions/VisualEditor/modules/es/models/es.DocumentModel.js |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | // It's an element, figure out it's type |
86 | 86 | var element = data[i], |
87 | 87 | type = element.type, |
88 | | - open = type[0] !== '/'; |
| 88 | + open = type.charAt( 0 ) !== '/'; |
89 | 89 | // Trim the "/" off the beginning of closing tag types |
90 | 90 | if ( !open ) { |
91 | 91 | type = type.substr( 1 ); |
— | — | @@ -148,7 +148,7 @@ |
149 | 149 | * @param {Object} annotation Annotation object to generate hash for |
150 | 150 | * @returns {String} Hash of annotation |
151 | 151 | */ |
152 | | -es.DocumentModel.getHash = typeof JSON.stringify === 'function' ? |
| 152 | +es.DocumentModel.getHash = ( window.JSON && typeof JSON.stringify === 'function' ) ? |
153 | 153 | JSON.stringify : es.JsonSerializer.stringify; |
154 | 154 | |
155 | 155 | /** |
Index: trunk/extensions/VisualEditor/modules/es/views/es.ContentView.js |
— | — | @@ -878,6 +878,7 @@ |
879 | 879 | leftPlain, |
880 | 880 | rightPlain, |
881 | 881 | stack = [], |
| 882 | + chr, |
882 | 883 | i, |
883 | 884 | j; |
884 | 885 | for ( i = 0; i < data.length; i++ ) { |
— | — | @@ -897,18 +898,19 @@ |
898 | 899 | } else if ( !leftPlain && !rightPlain ) { |
899 | 900 | // [formatted][formatted] pair, open/close any differences |
900 | 901 | for ( j = 1; j < left.length; j++ ) { |
901 | | - if ( right.indexOf( left[j] ) === -1 ) { |
| 902 | + if ( es.inArray( left[j], right ) ) { |
902 | 903 | out += render( 'close', left[j], stack ); |
903 | 904 | } |
904 | 905 | } |
905 | 906 | for ( j = 1; j < right.length; j++ ) { |
906 | | - if ( left.indexOf( right[j] ) === -1 ) { |
| 907 | + if ( es.inArray( right[j], left ) ) { |
907 | 908 | out += render( 'open', right[j], stack ); |
908 | 909 | } |
909 | 910 | } |
910 | 911 | } |
911 | | - out += right[0] in htmlChars ? htmlChars[right[0]] : right[0]; |
912 | | - left = right; |
| 912 | + chr = rightPlain ? right : right[0]; |
| 913 | + out += chr in htmlChars ? htmlChars[chr] : chr; |
| 914 | + left = right; |
913 | 915 | } |
914 | 916 | // Close all remaining tags at the end of the content |
915 | 917 | if ( !rightPlain && right ) { |