Skip to content

Commit 8a09eb0

Browse files
authored
Merge pull request #2264 from didi/feat-rn-ref-has-val
Feat rn ref has val
2 parents a030731 + 4bb4118 commit 8a09eb0

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

  • packages/webpack-plugin/lib/template-compiler

packages/webpack-plugin/lib/template-compiler/compiler.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,24 +1884,25 @@ function processRefReact (el, meta) {
18841884
/**
18851885
* selectorsConf: [type, [[prefix, selector], [prefix, selector]]]
18861886
*/
1887-
if (!val) {
1888-
const rawId = el.attrsMap.id
1889-
const rawClass = el.attrsMap.class
1890-
const rawDynamicClass = el.attrsMap[config[mode].directive.dynamicClass]
1891-
1892-
if (rawId) {
1893-
const staticId = parseMustacheWithContext(rawId).result
1894-
selectors.push({ prefix: '#', selector: `${staticId}` })
1895-
}
1896-
if (rawClass || rawDynamicClass) {
1897-
const staticClass = parseMustacheWithContext(rawClass).result
1898-
const dynamicClass = parseMustacheWithContext(rawDynamicClass).result
1899-
selectors.push({ prefix: '.', selector: `this.__getClass(${staticClass}, ${dynamicClass})` })
1900-
}
1901-
} else {
1887+
if (val) {
19021888
meta.refs.push(refConf)
19031889
selectors.push({ prefix: '', selector: `"${refConf.key}"` })
19041890
}
1891+
1892+
const rawId = el.attrsMap.id
1893+
const rawClass = el.attrsMap.class
1894+
const rawDynamicClass = el.attrsMap[config[mode].directive.dynamicClass]
1895+
1896+
if (rawId) {
1897+
const staticId = parseMustacheWithContext(rawId).result
1898+
selectors.push({ prefix: '#', selector: `${staticId}` })
1899+
}
1900+
if (rawClass || rawDynamicClass) {
1901+
const staticClass = parseMustacheWithContext(rawClass).result
1902+
const dynamicClass = parseMustacheWithContext(rawDynamicClass).result
1903+
selectors.push({ prefix: '.', selector: `this.__getClass(${staticClass}, ${dynamicClass})` })
1904+
}
1905+
19051906
const selectorsConf = selectors.map(item => `["${item.prefix}", ${item.selector}]`)
19061907
const refFnId = forScopes.reduce((preV, curV) => {
19071908
return `${preV} + "_" + ${curV.index}`

0 commit comments

Comments
 (0)