mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(compiler): fix single argument class and style interpolations (#50805)
Single argument class and style interpolations (e.g.
`style.color="{{color}"`) should be converted to standard class and
property operations with no interpolation (e.g. `[style.color]="color")
PR Close #50805
This commit is contained in:
parent
2f7072dc3f
commit
2fb5a847ca
1 changed files with 3 additions and 12 deletions
|
|
@ -358,7 +358,7 @@ const PROPERTY_INTERPOLATE_CONFIG: VariadicInstructionConfig = {
|
|||
*/
|
||||
const STYLE_PROP_INTERPOLATE_CONFIG: VariadicInstructionConfig = {
|
||||
constant: [
|
||||
null!, // Single argument stylePropInterpolate is converted to styleProp instruction.
|
||||
Identifiers.styleProp,
|
||||
Identifiers.stylePropInterpolate1,
|
||||
Identifiers.stylePropInterpolate2,
|
||||
Identifiers.stylePropInterpolate3,
|
||||
|
|
@ -373,9 +373,6 @@ const STYLE_PROP_INTERPOLATE_CONFIG: VariadicInstructionConfig = {
|
|||
if (n % 2 === 0) {
|
||||
throw new Error(`Expected odd number of arguments`);
|
||||
}
|
||||
if (n < 3) {
|
||||
throw new Error(`Expected at least 3 arguments`);
|
||||
}
|
||||
return (n - 1) / 2;
|
||||
},
|
||||
};
|
||||
|
|
@ -409,7 +406,7 @@ const ATTRIBUTE_INTERPOLATE_CONFIG: VariadicInstructionConfig = {
|
|||
*/
|
||||
const STYLE_MAP_INTERPOLATE_CONFIG: VariadicInstructionConfig = {
|
||||
constant: [
|
||||
null!, // Single argument styleMapInterpolate is converted to styleMap instruction.
|
||||
Identifiers.styleMap,
|
||||
Identifiers.styleMapInterpolate1,
|
||||
Identifiers.styleMapInterpolate2,
|
||||
Identifiers.styleMapInterpolate3,
|
||||
|
|
@ -424,9 +421,6 @@ const STYLE_MAP_INTERPOLATE_CONFIG: VariadicInstructionConfig = {
|
|||
if (n % 2 === 0) {
|
||||
throw new Error(`Expected odd number of arguments`);
|
||||
}
|
||||
if (n < 3) {
|
||||
throw new Error(`Expected at least 3 arguments`);
|
||||
}
|
||||
return (n - 1) / 2;
|
||||
},
|
||||
};
|
||||
|
|
@ -436,7 +430,7 @@ const STYLE_MAP_INTERPOLATE_CONFIG: VariadicInstructionConfig = {
|
|||
*/
|
||||
const CLASS_MAP_INTERPOLATE_CONFIG: VariadicInstructionConfig = {
|
||||
constant: [
|
||||
null!, // Single argument classMapInterpolate is converted to classMap instruction.
|
||||
Identifiers.classMap,
|
||||
Identifiers.classMapInterpolate1,
|
||||
Identifiers.classMapInterpolate2,
|
||||
Identifiers.classMapInterpolate3,
|
||||
|
|
@ -451,9 +445,6 @@ const CLASS_MAP_INTERPOLATE_CONFIG: VariadicInstructionConfig = {
|
|||
if (n % 2 === 0) {
|
||||
throw new Error(`Expected odd number of arguments`);
|
||||
}
|
||||
if (n < 3) {
|
||||
throw new Error(`Expected at least 3 arguments`);
|
||||
}
|
||||
return (n - 1) / 2;
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue