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

Is it possibily to exchange the order of ’// props' and '// setScopeId'? #6923

zollero opened this issue Oct 21, 2022 · 0 comments
feature request New feature or request


Copy link

zollero commented Oct 21, 2022

What problem does this feature solve?

What I will talk about is some code of function mountElement in this file.



I am trying to use Vue3 as A FrontEnd DSL for Weex, just use @vue/compiler-sfc, @vue/runtime-core and weex-vue-loader(forked from the latest vue-loader) to reach the goal.


This problem occurs when I resolve the <style> tag with the loader. My solution has two steps:

  1. Generate an object from <style> tag content with the component scopeId, and inject it to the runtime Weex document instance object in the weex-vue-loader(forked from the latest vue-loader), just like this:
  render: () => {...}
  styleSheets: {
    'data-v-b323823': {
      fontSize: 20,
      color: 'red'
  1. Custom the patchProp and nodeOps to createRenderer function of @vue/runtime-core, so I can set the style object to an element using the scopeId as the unique key of its component. Some Code like this:
export const nodeOps: Omit<
  RendererOptions<WeexNode, WeexElement>,
> = {
  insert: (child, parent, anchor) => {...},

  remove: child => {...},
  // this one
  setScopeId(el, id) {
    el.setAttr('id', id)

export const patchProp: DOMRendererOptions['patchProp'] = (
  isSVG = false,
) => {
  if (key === 'class') {
    patchClass(el, nextValue)

export function patchClass(el: WeexElement, value: string | null) {
  const classList = processClassStr(value); // array of class, like ['title']
  // get the unique style object from weex document instance by scopeId
  const styleObj = Object.assign(
    ...( => (
      weex.document.styleSheets[el.scopeId + '-' + item] // Wow, I can't get the scopeId

  // set the full style object to the element

More description

From the demo code above, patchClass runs before setScopeId, so I can't get the scopeId in patchClass. And it is just because props initiates before setScopeId in mountElement . file path

What does the proposed API look like?

So I want to ask if it is possible to exchange the order of props initiate and setScopeId, like the image below.


@zollero zollero added the feature request New feature or request label Oct 21, 2022
chrislone pushed a commit to chrislone/core that referenced this issue Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
feature request New feature or request
None yet

No branches or pull requests

1 participant