This repository has been archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复支付宝自定义组件使用 component2 模式报错的问题
- Loading branch information
Showing
57 changed files
with
1,636 additions
and
784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/remax-cli/src/__tests__/fixtures/alipay/expected/packageA/pages/index.axml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/remax-cli/src/__tests__/fixtures/alipay/expected/pages/index.axml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/remax-cli/src/__tests__/fixtures/assets/expected/pages/index.axml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/remax-cli/src/__tests__/fixtures/babelrc/expected/pages/index.axml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/remax-cli/src/__tests__/fixtures/compressTemplate/expected/pages/index.wxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<wxs src="../helper.wxs" module="helper" /> <import src="../base.wxml"/> <template is="REMAX_TPL" data="{{tree: helper.reduce(action)}}" /> | ||
<wxs src="./helper.wxs" module="helper" /> <import src="../base.wxml"/> <template is="REMAX_TPL" data="{{tree: helper.reduce(action)}}" /> |
115 changes: 115 additions & 0 deletions
115
...ges/remax-cli/src/__tests__/fixtures/createHostComponent/expected/alipay/pages/helper.sjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
var tree = { | ||
root: { | ||
children: [], | ||
}, | ||
lastActionId: -1 | ||
}; | ||
|
||
function reduce(action) { | ||
if (action.id === tree.lastActionId) { | ||
return tree; | ||
} | ||
|
||
tree.lastActionId = action.id; | ||
|
||
switch (action.type) { | ||
case 'init': | ||
tree = { | ||
root: { | ||
children: [ | ||
action.payload[0].item, | ||
] | ||
}, | ||
lastActionId: -1, | ||
}; | ||
return tree; | ||
case 'clear': | ||
tree.root = { | ||
children: [] | ||
}; | ||
return tree; | ||
case 'splice': | ||
for (var i = 0; i < action.payload.length; i += 1) { | ||
var value = get(tree, action.payload[i].path); | ||
if (action.payload[i].item) { | ||
value.splice( | ||
action.payload[i].start, | ||
action.payload[i].deleteCount, | ||
action.payload[i].item | ||
); | ||
} else { | ||
value.splice(action.payload[i].start, action.payload[i].deleteCount); | ||
} | ||
set(tree, action.payload[i].path, value); | ||
} | ||
return tree; | ||
default: | ||
return tree; | ||
} | ||
} | ||
|
||
function getKey(key) { | ||
var intKey = parseInt(key); | ||
if (intKey.toString() === key) { | ||
return intKey; | ||
} | ||
return key; | ||
} | ||
|
||
function set(obj, path, value) { | ||
if (typeof path === 'string') { | ||
path = path.split('.').map(getKey); | ||
} | ||
|
||
if (path.length === 1) { | ||
obj[path[0]] = value; | ||
} | ||
|
||
var nextObj = obj; | ||
for (var i = 0; i < path.length; i += 1) { | ||
var currentPath = path[i]; | ||
var currentValue = nextObj[currentPath]; | ||
|
||
if (currentValue === void 0) { | ||
//check if we assume an array | ||
if (typeof path[i + 1] === 'number') { | ||
nextObj[currentPath] = []; | ||
} else { | ||
nextObj[currentPath] = {}; | ||
} | ||
} | ||
|
||
if (i === path.length - 1) { | ||
nextObj[currentPath] = value; | ||
} | ||
|
||
nextObj = nextObj[currentPath]; | ||
} | ||
} | ||
|
||
function get(obj, path) { | ||
if (typeof path === 'string') { | ||
path = path.split('.').map(getKey); | ||
} | ||
|
||
var nextObj = obj; | ||
for (var i = 0; i < path.length; i += 1) { | ||
var currentPath = path[i]; | ||
nextObj = nextObj[currentPath]; | ||
if (nextObj === void 0) { | ||
if (currentPath === 'children') { | ||
nextObj = []; | ||
} else { | ||
nextObj = {}; | ||
} | ||
} | ||
} | ||
|
||
return nextObj; | ||
} | ||
|
||
|
||
export default { | ||
reduce | ||
} | ||
|
2 changes: 1 addition & 1 deletion
2
...ges/remax-cli/src/__tests__/fixtures/createHostComponent/expected/alipay/pages/index.axml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ges/remax-cli/src/__tests__/fixtures/createHostComponent/expected/wechat/pages/index.wxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<wxs src="../helper.wxs" module="helper" /> | ||
<wxs src="./helper.wxs" module="helper" /> | ||
<import src="../base.wxml"/> | ||
<template is="REMAX_TPL" data="{{tree: helper.reduce(action)}}" /> |
105 changes: 0 additions & 105 deletions
105
packages/remax-cli/src/__tests__/fixtures/customRootDir/expected/helper.sjs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.