Skip to content

Commit

Permalink
fix: 修复 getPxTransform 中无配置 deviceRatio 时报错的问题 (#14352)
Browse files Browse the repository at this point in the history
* fix: 修复 getPxTransform 中无配置 deviceRatio 时报错的问题

* test: update snapshots

* test: update snapshot

---------

Co-authored-by: Zakary <zakarycode@gmail.com>
  • Loading branch information
onfuns and ZakaryCode authored Aug 17, 2023
1 parent 2dae08a commit c71ad63
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/taro-api/src/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function getPxTransform (taro) {
throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)
}
const formatSize = ~~size
let rootValue = 1 / config.deviceRatio[designWidth]
let rootValue = 1 / deviceRatio[designWidth]
switch (config.targetUnit) {
case 'rem':
rootValue *= baseFontSize * 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ exports[`babel should convert do expressions 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ exports[`compiler-macros - defineAppConfig and definePageConfig should read app
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ exports[`config should build from origin and pipe to output 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down Expand Up @@ -1827,7 +1827,7 @@ I m irrelevant.
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down Expand Up @@ -2762,7 +2762,7 @@ exports[`config should resolved alias 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ exports[`css modules should use css modules with global mode 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down Expand Up @@ -1855,7 +1855,7 @@ exports[`css modules should use css modules with module mode 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ exports[`nerv should build nerv app 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ exports[`react should build react app 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ exports[`sass should build app with sass 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down Expand Up @@ -1798,7 +1798,7 @@ exports[`sass should build app with scss 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down Expand Up @@ -2729,7 +2729,7 @@ exports[`sass should set global sass content with data 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down Expand Up @@ -3660,7 +3660,7 @@ exports[`sass should set global sass content with source & dir 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down Expand Up @@ -4591,7 +4591,7 @@ exports[`sass should set global sass content with source 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ exports[`subpackages should process subpackages 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ exports[`typescript should build project with ts 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ exports[`vue should build vue app 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ exports[`vue3 should build vue3 app 2`] = `
throw new Error("deviceRatio 配置中不存在 ".concat(designWidth, " 的设置!"));
}
var formatSize = ~~size;
var rootValue = 1 / config.deviceRatio[designWidth];
var rootValue = 1 / deviceRatio[designWidth];
switch (config.targetUnit) {
case "rem":
rootValue *= baseFontSize * 2;
Expand Down

0 comments on commit c71ad63

Please sign in to comment.