New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[weex]TypeError: CreateListFromArrayLike called on non-object #9124

Closed
ts0307 opened this Issue Nov 29, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@ts0307

ts0307 commented Nov 29, 2018

Version

2.5.17

Reproduction link

Steps to reproduce


<template>
    <text :class="textStyle">test</text>
</template>
<script>
export default {
  name: 'App',
  data () {
    return {
      textStyle: 'red' // is wrong
      // textStyle: ['red'] // is ok
    }
  },
}
</script>

<style scoped>
  .red {
    color: #FF0000;
  }
  .green {
    color: #00FF00;
  }
</style>

What is expected?

If textStyle is set to 'red', the data.class type is String, so the following code runs incorrectly.
If textStyle is set to ['red'], the data.class type is Array, so the following code works fine.

What is actually happening?


This bug occurs in the platform "weex". In the function "src/platforms/weex/runtime/modules/class.js/updateClass", the following two lines of code:

if (oldData.class) { oldClassList.push.apply(oldClassList, oldData.class) }
if (data.class) { classList.push.apply(classList, data.class) }

Because the types of "oldData.class" and "data.class" are strings, not "Array" required by "apply".

@posva

This comment has been minimized.

Member

posva commented Nov 29, 2018

@ts0307 Some vue code will probably help @Hanks10100 to check this

@posva posva added the weex label Nov 29, 2018

@ts0307

This comment has been minimized.

ts0307 commented Dec 3, 2018

@Hanks10100 @posva I have provided an example to reproduce this problem

@Hanks10100

This comment has been minimized.

Collaborator

Hanks10100 commented Dec 4, 2018

@ts0307 Thanks for your remind, I put your demo on the weex playground.

The code you point out had been changed to this https://github.com/vuejs/vue/pull/7930/files#diff-c4874f4bae144c328950ba14ed7601abR35 . It will not throw errors when the type of data.class is not array, but still doesn't support binding plain text yet. We can fix it later.

@Hanks10100

This comment has been minimized.

Collaborator

Hanks10100 commented Dec 4, 2018

Refer to #9139

@ts0307

This comment has been minimized.

ts0307 commented Dec 4, 2018

good job!

@yyx990803 yyx990803 closed this in d8285c5 Dec 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment