Skip to content

Commit

Permalink
fix quote BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
RubyLouvre committed Aug 20, 2014
1 parent 8506815 commit c4e7e7d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions avalon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2335,8 +2335,8 @@
'"': '\\"',
'\\': '\\\\'
};
var quote = window.JSON && JSON.stringify || function() {
return '"' + this.replace(/[\\\"\x00-\x1f]/g, function(a) {
var quote = window.JSON && JSON.stringify || function(str) {
return '"' + str.replace(/[\\\"\x00-\x1f]/g, function(a) {
var c = meta[a];
return typeof c === 'string' ? c :
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
Expand Down
4 changes: 2 additions & 2 deletions avalon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ void function() {
clickEvent.markFastClick = "司徒正美";
element.dispatchEvent(clickEvent)
},
focus: function(targetElement) {
if (this.canFocus(targetElement)) {
var length;
// Issue #160: on iOS 7, some input elements (e.g. date datetime) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
if (isIOS && targetElement.setSelectionRange && targetElement.type.indexOf("date") !== 0 && targetElement.type !== 'time') {
length = targetElement.value.length
targetElement.setSelectionRange(length, length)
focus: function(target) {
if (this.canFocus(target)) {
//https://github.com/RubyLouvre/avalon/issues/254
var value = target.value
target.value = value
if (isIOS && target.setSelectionRange && target.type.indexOf("date") !== 0 && target.type !== 'time') {
// iOS 7, date datetime等控件直接对selectionStart,selectionEnd赋值会抛错
var n = value.length
target.setSelectionRange(n, n)
} else {
targetElement.focus()
target.focus()
}
}
},
Expand Down

0 comments on commit c4e7e7d

Please sign in to comment.