Skip to content

Commit

Permalink
Merge pull request #1586 from wg5945/1584
Browse files Browse the repository at this point in the history
PopupPicker:Fix a bug caused by unexpected end of json value
  • Loading branch information
wg5946 authored Jun 20, 2017
2 parents 8d50a40 + 4160f70 commit 3d95b28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/components/picker/metas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,8 @@ changes:
- '[enhance] Support PC mouse drag #1039 @michael829'
zh-CN:
- '[enhance] 支持 PC 上鼠标选择 #1039 @michael829'
next:
en:
- '[fix] Fix a bug caused by unexpected end of json value #1584'
zh-CN:
- '[fix] 修复json格式不正确引起的bug #1584'
8 changes: 4 additions & 4 deletions src/components/picker/scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ var Scroller = function (container, options) {
var html = ''
if (data.length && data[0].constructor === Object) {
data.forEach(function (row) {
html += '<div class="' + self.options.itemClass + '" data-value=' + JSON.stringify({value: row.value}) + '>' + row.name + '</div>'
html += '<div class="' + self.options.itemClass + '" data-value=' + JSON.stringify({value: encodeURI(row.value)}) + '>' + row.name + '</div>'
})
} else {
data.forEach(function (val) {
html += '<div class="' + self.options.itemClass + '" data-value=' + JSON.stringify({value: val}) + '>' + val + '</div>'
html += '<div class="' + self.options.itemClass + '" data-value=' + JSON.stringify({value: encodeURI(val)}) + '>' + val + '</div>'
})
}
content.innerHTML = html
Expand Down Expand Up @@ -156,7 +156,7 @@ var members = {

var children = self.__content.children
for (var i = 0, len = children.length; i < len; i++) {
if (JSON.parse(children[i].dataset.value).value === value) {
if (decodeURI(JSON.parse(children[i].dataset.value).value) === value) {
self.selectByIndex(i, animate)
return
}
Expand Down Expand Up @@ -208,7 +208,7 @@ var members = {
self.__prevValue = self.value
}

self.value = JSON.parse(selectedItem.dataset.value).value
self.value = decodeURI(JSON.parse(selectedItem.dataset.value).value)
},

__scrollingComplete () {
Expand Down

0 comments on commit 3d95b28

Please sign in to comment.