Skip to content

Commit

Permalink
fix(hippy-vue): remove vue other attributes converted to number
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomchan-cxj committed Nov 16, 2021
1 parent a034c69 commit 8ce311a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/js/entry/android/hippy.js
Expand Up @@ -9,7 +9,7 @@ require('../../global/TimerModule.js'); // setTimeout clearTimeout setInterval c
require('../../global/ConsoleModule.js'); // console
require('../../global/UIManagerModule.js'); // Hippy.document
require('../../global/Network.js'); // Headers fetch Response
require('../../global/Storage.js'); // localStrorageAsync
require('../../global/Storage.js'); // localStorageAsync
require('../../global/Event.js'); // dealloc event
require('../../global/android/Dimensions.js'); // Hippy.device.window Hippy.device.screen Hippy.device.pixelRatio
require('../../global/UtilsModule.js'); // Hippy.device.vibrate Hippy.device.cancelVibrate
Expand Down
Expand Up @@ -53,7 +53,7 @@
>
<label>文本(限制5个字符):</label>
<input
maxlength="5"
:maxlength="5"
placeholder="5 个字符"
class="input"
@change="textChange"
Expand Down
8 changes: 5 additions & 3 deletions examples/hippy-vue-demo/src/main-native.js
Expand Up @@ -48,10 +48,12 @@ const app = new Vue({

/**
* $start 是 Hippy 启动完以后触发的回调
* Vue 会在 Hippy 启动之前完成首屏 VDOM 的渲染,所以首屏性能非常高
* 在 $start 里可以通知终端说已经启动完成,可以开始给前端发消息了。
* @param {Function} callback - 引擎加载成功后回调函数
* @param {Object} instance - 业务vue实例对象
* @param {Object} initialProps - 终端给前端的初始化参数
*/
app.$start((/* app */) => {
app.$start((instance, initialProps) => {
console.log('instance', instance, 'initialProps', initialProps);
// 这里干一点 Hippy 启动后的需要干的事情,比如通知终端前端已经准备完毕,可以开始发消息了。
// setApp(app);
// listen Android back press
Expand Down
Expand Up @@ -74,6 +74,8 @@ test('Element.removeAttribute test', (t) => {
const testNode = new ElementNode('div');
const key = 'test';
testNode.setAttribute(key, '123');
t.is(testNode.getAttribute(key), '123');
testNode.setAttribute(key, 123);
t.is(testNode.getAttribute(key), 123);
testNode.removeAttribute(key);
t.is(testNode.getAttribute(key), undefined);
Expand Down
2 changes: 1 addition & 1 deletion packages/hippy-vue/src/renderer/element-node.js
Expand Up @@ -291,7 +291,7 @@ class ElementNode extends ViewNode {
this.attributes['caret-color'] = Native.parseColor(value);
break;
default:
this.attributes[key] = tryConvertNumber(value);
this.attributes[key] = value;
}

updateChild(this);
Expand Down
Expand Up @@ -848,6 +848,8 @@ test('text element with number text test', (t) => {
parentNode.setText(0);
parentNode.setAttribute('test', '123');
t.is(parentNode.getAttribute('text'), '0');
t.is(parentNode.getAttribute('test'), '123');
parentNode.setAttribute('test', 123);
t.is(parentNode.getAttribute('test'), 123);
// debug mode
process.env.NODE_ENV = 'test';
Expand Down

0 comments on commit 8ce311a

Please sign in to comment.