@tarojs/taro-h5
Advanced tools
Comparing version 0.0.54 to 0.0.55
{ | ||
"name": "@tarojs/taro-h5", | ||
"version": "0.0.54", | ||
"version": "0.0.55", | ||
"description": "Taro h5 framework", | ||
@@ -27,8 +27,9 @@ "main": "index.js", | ||
"peerDependencies": { | ||
"nervjs": "^1.2.17" | ||
"nervjs": "^1.3.0" | ||
}, | ||
"dependencies": { | ||
"@tarojs/taro": "0.0.54", | ||
"@tarojs/taro": "0.0.55", | ||
"jsonp-retry": "^1.0.3", | ||
"nervjs": "^1.2.18" | ||
"nervjs": "^1.3.0", | ||
"whatwg-fetch": "^2.0.4" | ||
}, | ||
@@ -35,0 +36,0 @@ "devDependencies": { |
@@ -26,3 +26,3 @@ /** | ||
const { id, dataset, rect, size, scrollOffset, properties = [] } = fields | ||
const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [] } = fields | ||
const { left, right, top, bottom, width, height } = dom.getBoundingClientRect() | ||
@@ -59,5 +59,13 @@ const isViewport = selector === 'html' | ||
properties.forEach(prop => { | ||
res[prop] = dom.getAttribute(prop) | ||
const attr = dom.getAttribute(prop) | ||
if (attr) res[prop] = attr | ||
}) | ||
} | ||
if (computedStyle.length) { | ||
const styles = window.getComputedStyle(dom) | ||
computedStyle.forEach(key => { | ||
const value = styles.getPropertyValue(key) | ||
if (value) res[key] = value | ||
}) | ||
} | ||
@@ -83,3 +91,3 @@ return res | ||
// 小程序里跨自定义组件的后代选择器 '>>>' 在 h5 替换为普通后代选择器 '>' | ||
selector = selector.replace('>>>', '>') | ||
if (typeof selector === 'string') selector = selector.replace('>>>', '>') | ||
return new NodesRef(selector, this, true) | ||
@@ -90,3 +98,3 @@ } | ||
// 小程序里跨自定义组件的后代选择器 '>>>' 在 h5 替换为普通后代选择器 '>' | ||
selector = selector.replace('>>>', '>') | ||
if (typeof selector === 'string') selector = selector.replace('>>>', '>') | ||
return new NodesRef(selector, this, false) | ||
@@ -142,3 +150,3 @@ } | ||
const { _selector, _component, _single, _selectorQuery } = this | ||
const { id, dataset, rect, size, scrollOffset, properties = [] } = fields | ||
const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [] } = fields | ||
@@ -151,3 +159,4 @@ _selectorQuery._push(_selector, _component, _single, { | ||
scrollOffset, | ||
properties | ||
properties, | ||
computedStyle | ||
}, cb) | ||
@@ -154,0 +163,0 @@ |
@@ -114,2 +114,3 @@ import { inlineStyle } from '../utils' | ||
config.complete(res) | ||
this.rejectHandler(res) | ||
} | ||
@@ -125,2 +126,7 @@ mask.onclick = cb | ||
}, 0) | ||
return new Promise((resolve, reject) => { | ||
this.resolveHandler = resolve | ||
this.rejectHandler = reject | ||
}) | ||
} | ||
@@ -175,2 +181,7 @@ | ||
}, 0) | ||
return new Promise((resolve, reject) => { | ||
this.resolveHandler = resolve | ||
this.rejectHandler = reject | ||
}) | ||
} | ||
@@ -182,6 +193,7 @@ | ||
errMsg: 'showActionSheet:ok', | ||
tapIndex: e.currentTarget.dataset.tapIndex | ||
tapIndex: +e.currentTarget.dataset.tapIndex | ||
} | ||
this.options.success(res) | ||
this.options.complete(res) | ||
this.resolveHandler(res) | ||
} | ||
@@ -188,0 +200,0 @@ |
@@ -91,7 +91,13 @@ import { errorHandler, getParameterError } from '../utils' | ||
// verify options | ||
const handler = errorHandler(options.fail, options.complete) | ||
if (typeof options.title !== 'string') { | ||
const err = { errMsg: getParameterError('showLoading', 'title', 'String', typeof options.title) } | ||
options.fail && options.fail(err) | ||
options.complete && options.complete(err) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showLoading', | ||
para: 'title', | ||
correct: 'String', | ||
wrong: options.title | ||
}) | ||
}) | ||
} | ||
@@ -102,3 +108,3 @@ | ||
if (!toast.el) return toast.create(options) | ||
toast.show(options) | ||
return toast.show(options) | ||
} | ||
@@ -129,39 +135,73 @@ | ||
if (typeof options.title !== 'string') { | ||
handler({errMsg: getParameterError('showModal', 'title', 'String', typeof options.title)}) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showModal', | ||
para: 'title', | ||
correct: 'String', | ||
wrong: options.title | ||
}) | ||
}) | ||
} | ||
if (typeof options.content !== 'string') { | ||
handler({errMsg: getParameterError('showModal', 'content', 'String', typeof options.content)}) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showModal', | ||
para: 'content', | ||
correct: 'String', | ||
wrong: options.content | ||
}) | ||
}) | ||
} | ||
if (typeof options.cancelText !== 'string') { | ||
handler({errMsg: getParameterError('showModal', 'cancelText', 'String', typeof options.cancelText)}) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showModal', | ||
para: 'cancelText', | ||
correct: 'String', | ||
wrong: options.cancelText | ||
}) | ||
}) | ||
} | ||
if (options.cancelText.length > 4) { | ||
handler({errMsg: 'showModal: fail cancelText length should not large then 4'}) | ||
return | ||
if (options.cancelText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) { | ||
return handler({ errMsg: 'showModal:fail cancelText length should not larger then 4 Chinese characters' }) | ||
} | ||
if (typeof options.confirmText !== 'string') { | ||
handler({errMsg: getParameterError('showModal', 'confirmText', 'String', typeof options.confirmText)}) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showModal', | ||
para: 'confirmText', | ||
correct: 'String', | ||
wrong: options.confirmText | ||
}) | ||
}) | ||
} | ||
if (options.confirmText.length > 4) { | ||
handler({errMsg: 'showModal: fail confirmText length should not large then 4'}) | ||
return | ||
if (options.confirmText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) { | ||
return handler({ errMsg: 'showModal:fail confirmText length should not larger then 4 Chinese characters' }) | ||
} | ||
if (typeof options.cancelColor !== 'string') { | ||
handler({errMsg: getParameterError('showModal', 'cancelColor', 'String', typeof options.cancelColor)}) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showModal', | ||
para: 'cancelColor', | ||
correct: 'String', | ||
wrong: options.cancelColor | ||
}) | ||
}) | ||
} | ||
if (typeof options.confirmColor !== 'string') { | ||
handler({errMsg: getParameterError('showModal', 'confirmColor', 'String', typeof options.confirmColor)}) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showModal', | ||
para: 'confirmColor', | ||
correct: 'String', | ||
wrong: options.confirmColor | ||
}) | ||
}) | ||
} | ||
@@ -172,3 +212,3 @@ | ||
if (!modal.el) return modal.create(options) | ||
modal.show(options) | ||
return modal.show(options) | ||
} | ||
@@ -189,14 +229,18 @@ | ||
if (!Array.isArray(options.itemList)) { | ||
handler({errMsg: getParameterError('showActionSheet', 'itemList', 'Array', typeof options.itemList)}) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showActionSheet', | ||
para: 'itemList', | ||
correct: 'Array', | ||
wrong: options.itemList | ||
}) | ||
}) | ||
} | ||
if (options.itemList.length < 1) { | ||
handler({errMsg: 'showActionSheet:fail parameter error:parameter.itemList should have at least 1 item'}) | ||
return | ||
return handler({ errMsg: 'showActionSheet:fail parameter error: parameter.itemList should have at least 1 item' }) | ||
} | ||
if (options.itemList.length > 6) { | ||
handler({errMsg: 'showActionSheet:fail parameter error:parameter.itemList should not be large than 6'}) | ||
return | ||
return handler({ errMsg: 'showActionSheet:fail parameter error: parameter.itemList should not be large than 6' }) | ||
} | ||
@@ -206,4 +250,10 @@ | ||
if (typeof options.itemList[i] !== 'string') { | ||
handler({errMsg: getParameterError('showActionSheet', `itemList[${i}]`, 'String', typeof options.itemList[i])}) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showActionSheet', | ||
para: `itemList[${i}]`, | ||
correct: 'String', | ||
wrong: options.itemList[i] | ||
}) | ||
}) | ||
} | ||
@@ -213,10 +263,16 @@ } | ||
if (typeof options.itemColor !== 'string') { | ||
handler({errMsg: getParameterError('showActionSheet', 'itemColor', 'String', typeof options.itemColor)}) | ||
return | ||
return handler({ | ||
errMsg: getParameterError({ | ||
name: 'showActionSheet', | ||
para: 'itemColor', | ||
correct: 'String', | ||
wrong: options.itemColor | ||
}) | ||
}) | ||
} | ||
if (!actionSheet.el) return actionSheet.create(options) | ||
actionSheet.show(options) | ||
return actionSheet.show(options) | ||
} | ||
export { showToast, hideToast, showLoading, hideLoading, showModal, showActionSheet } |
@@ -125,4 +125,5 @@ import { inlineStyle } from '../utils' | ||
const res = this.getRes('cancel') | ||
config.fail(res) | ||
config.success(res) | ||
config.complete(res) | ||
this.resolveHandler(res) | ||
} | ||
@@ -141,2 +142,3 @@ | ||
config.complete(res) | ||
this.resolveHandler(res) | ||
} | ||
@@ -156,2 +158,4 @@ | ||
setTimeout(() => { this.el.style.opacity = '1' }, 0) | ||
return new Promise(resolve => (this.resolveHandler = resolve)) | ||
} | ||
@@ -215,4 +219,5 @@ | ||
const res = this.getRes('cancel') | ||
config.fail(res) | ||
config.success(res) | ||
config.complete(res) | ||
this.resolveHandler(res) | ||
} | ||
@@ -224,2 +229,3 @@ this.confirm.onclick = () => { | ||
config.complete(res) | ||
this.resolveHandler(res) | ||
} | ||
@@ -230,2 +236,4 @@ | ||
setTimeout(() => { this.el.style.opacity = '1' }, 0) | ||
return new Promise(resolve => (this.resolveHandler = resolve)) | ||
} | ||
@@ -232,0 +240,0 @@ |
@@ -142,3 +142,3 @@ import { inlineStyle } from '../utils' | ||
const errMsg = 'showToast:ok' | ||
const errMsg = this.type === 'loading' ? 'showLoading:ok' : 'showToast:ok' | ||
config.success && config.success({ errMsg }) | ||
@@ -200,3 +200,3 @@ config.complete && config.complete({ errMsg }) | ||
const errMsg = 'showToast:ok' | ||
const errMsg = this.type === 'loading' ? 'showLoading:ok' : 'showToast:ok' | ||
config.success && config.success({ errMsg }) | ||
@@ -203,0 +203,0 @@ config.complete && config.complete({ errMsg }) |
@@ -0,1 +1,2 @@ | ||
import 'whatwg-fetch' | ||
import jsonpRetry from 'jsonp-retry' | ||
@@ -33,3 +34,3 @@ | ||
params.headers = options.header | ||
params.method = options.method | ||
params.method = options.method || 'GET' | ||
params.mode = options.mode | ||
@@ -36,0 +37,0 @@ params.credentials = options.credentials |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1096875
30
14842
5
+ Addedwhatwg-fetch@^2.0.4
+ Added@tarojs/taro@0.0.55(transitive)
+ Addedwhatwg-fetch@2.0.4(transitive)
- Removed@tarojs/taro@0.0.54(transitive)
Updated@tarojs/taro@0.0.55
Updatednervjs@^1.3.0