Skip to content
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
Closed

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

ts0307 opened this issue Nov 29, 2018 · 5 comments
Labels

Comments

@ts0307
Copy link

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
Copy link
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
Copy link
Author

ts0307 commented Dec 3, 2018

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

@Hanks10100
Copy link
Contributor

@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
Copy link
Contributor

Refer to #9139

@ts0307
Copy link
Author

ts0307 commented Dec 4, 2018

good job!

f2009 pushed a commit to f2009/vue that referenced this issue Jan 25, 2019
aJean pushed a commit to aJean/vue that referenced this issue Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants