@conecli/cone-render 0.10.1-shop3.85 → 0.10.1-shop3.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/accessibility.h5.ts +1 -1
- package/dist/common/const.ts +1 -1
- package/dist/components/base/NetworkDataError/const.ts +1 -1
- package/dist/components/base/NetworkDataError/index.module.scss +1 -1
- package/dist/interface/jumpEventReport.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.h5.ts +1 -1
- package/dist/language/en_US.json +22 -0
- package/dist/language/zh_CN.json +22 -0
- package/dist/language/zh_HK.json +22 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro';
|
|
2
1
|
'app-activity',
|
|
3
2
|
'app-rank',
|
|
4
3
|
'app-seckill',
|
|
5
4
|
'm-coupon',
|
|
6
5
|
'scene-buy',
|
|
7
6
|
'light-details',
|
|
8
7
|
'app-introduce',
|
|
9
8
|
if (window?.shopGlobalSwitch?.openAccessibilityLanguage) {
|
|
10
9
|
Taro.nextTick(() => {
|
|
11
10
|
const htmlRoot = document?.documentElement;
|
|
12
11
|
htmlRoot && htmlRoot.setAttribute('lang', isLanguageForEn ? 'en' : 'zh-CN');
|
|
13
12
|
});
|
|
14
13
|
}
|
|
15
14
|
const mainConfig = {
|
|
16
15
|
childList: true,
|
|
17
16
|
subtree: true,
|
|
18
17
|
attributes: true,
|
|
19
18
|
attributeFilter: ['auto-accessible'],
|
|
20
19
|
};
|
|
21
20
|
const mainObserver = new MutationObserver(function (mutations) {
|
|
22
21
|
mutations.forEach(function (mutation) {
|
|
23
22
|
if (mutation.type === 'childList') {
|
|
24
23
|
mutation.addedNodes.forEach(function (node) {
|
|
25
24
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
26
25
|
if (node.hasAttribute && node.getAttribute('auto-accessible') === 'true') {
|
|
27
26
|
updateAccessibilityLabel(node);
|
|
28
27
|
}
|
|
29
28
|
const accessibleElements = node.querySelectorAll
|
|
30
29
|
? node.querySelectorAll('[auto-accessible="true"]')
|
|
31
30
|
: [];
|
|
32
31
|
accessibleElements.forEach(function (el) {
|
|
33
32
|
updateAccessibilityLabel(el);
|
|
34
33
|
});
|
|
35
34
|
}
|
|
36
35
|
});
|
|
37
36
|
}
|
|
38
37
|
if (mutation.type === 'attributes' && mutation.attributeName === 'auto-accessible') {
|
|
39
38
|
if (mutation.target.getAttribute('auto-accessible') === 'true') {
|
|
40
39
|
updateAccessibilityLabel(mutation.target);
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
});
|
|
44
43
|
});
|
|
45
44
|
mainObserver.observe(document.body, mainConfig);
|
|
46
45
|
setupGlobalContentObserver();
|
|
47
46
|
const contentConfig = {
|
|
48
47
|
characterData: true,
|
|
49
48
|
childList: true,
|
|
50
49
|
subtree: true,
|
|
51
50
|
};
|
|
52
51
|
const lastUpdateTime = new WeakMap();
|
|
53
52
|
const THROTTLE_DELAY = 2000;
|
|
54
53
|
|
|
55
54
|
function shouldUpdate(element) {
|
|
56
55
|
const now = Date.now();
|
|
57
56
|
const lastTime = lastUpdateTime.get(element);
|
|
58
57
|
if (!lastTime || now - lastTime >= THROTTLE_DELAY) {
|
|
59
58
|
lastUpdateTime.set(element, now);
|
|
60
59
|
return true;
|
|
61
60
|
}
|
|
62
61
|
return false;
|
|
63
62
|
}
|
|
64
63
|
const globalContentObserver = new MutationObserver(function (mutations) {
|
|
65
64
|
const affectedElements = new Set();
|
|
66
65
|
mutations.forEach(function (mutation) {
|
|
67
66
|
let targetElement = null;
|
|
68
67
|
if (mutation.type === 'characterData') {
|
|
69
68
|
targetElement = findClosestAccessibleElement(mutation.target);
|
|
70
69
|
} else if (mutation.type === 'childList') {
|
|
71
70
|
targetElement = findClosestAccessibleElement(mutation.target);
|
|
72
71
|
}
|
|
73
72
|
if (targetElement && targetElement.getAttribute('auto-accessible') === 'true') {
|
|
74
73
|
affectedElements.add(targetElement);
|
|
75
74
|
}
|
|
76
75
|
});
|
|
77
76
|
affectedElements.forEach(function (element) {
|
|
78
77
|
if (shouldUpdate(element)) {
|
|
79
78
|
updateAccessibilityLabel(element);
|
|
80
79
|
} else {
|
|
81
80
|
}
|
|
82
81
|
});
|
|
83
82
|
});
|
|
84
83
|
globalContentObserver.observe(document.body, contentConfig);
|
|
85
84
|
let current = node;
|
|
86
85
|
if (current.nodeType === Node.TEXT_NODE) {
|
|
87
86
|
current = current.parentElement;
|
|
88
87
|
}
|
|
89
88
|
while (current && current !== document.body) {
|
|
90
89
|
if (current.getAttribute && current.getAttribute('auto-accessible') === 'true') {
|
|
91
90
|
return current;
|
|
92
91
|
}
|
|
93
92
|
current = current.parentElement;
|
|
94
93
|
}
|
|
95
94
|
return null;
|
|
96
95
|
if (!element) return;
|
|
97
96
|
if (element.hasAttribute('aria-label')) {
|
|
98
97
|
completeA11yAttributes(element);
|
|
99
98
|
if (!element.getAttribute('data-auto-aria-label')) {
|
|
100
99
|
return;
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
const text = element.innerText;
|
|
104
103
|
if (text) {
|
|
105
104
|
const processedText = text.replace(/\r|\n/g, ' ').replace(/¥\s(\d+)(\s(\.\d+))?/, '¥$1$3');
|
|
106
105
|
element.setAttribute('aria-label', processedText);
|
|
107
106
|
element.setAttribute('data-auto-aria-label', 'true');
|
|
108
107
|
completeA11yAttributes(element);
|
|
109
108
|
}
|
|
110
109
|
if (!element.hasAttribute('role')) {
|
|
111
110
|
element.setAttribute('role', 'text');
|
|
112
111
|
}
|
|
113
112
|
if (!element.hasAttribute('tabindex')) {
|
|
114
113
|
element.setAttribute('tabindex', 0);
|
|
115
114
|
}
|
|
116
115
|
console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
|
|
117
116
|
setupMainObserver();
|
|
118
117
|
console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);
|
|
118
|
+
import Taro from '@tarojs/taro';
|
|
119
119
|
'app-activity',
|
|
120
120
|
'app-rank',
|
|
121
121
|
'app-seckill',
|
|
122
122
|
'm-coupon',
|
|
123
123
|
'scene-buy',
|
|
124
124
|
'light-details',
|
|
125
125
|
'member-paid-center',
|
|
126
126
|
'member-paid-card',
|
|
127
127
|
'member-paid-bind',
|
|
128
128
|
'app-introduce',
|
|
129
129
|
if (window?.shopGlobalSwitch?.openAccessibilityLanguage) {
|
|
130
130
|
Taro.nextTick(() => {
|
|
131
131
|
const htmlRoot = document?.documentElement;
|
|
132
132
|
htmlRoot && htmlRoot.setAttribute('lang', isLanguageForEn ? 'en' : 'zh-CN');
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
const mainConfig = {
|
|
136
136
|
childList: true,
|
|
137
137
|
subtree: true,
|
|
138
138
|
attributes: true,
|
|
139
139
|
attributeFilter: ['auto-accessible'],
|
|
140
140
|
};
|
|
141
141
|
const mainObserver = new MutationObserver(function (mutations) {
|
|
142
142
|
mutations.forEach(function (mutation) {
|
|
143
143
|
if (mutation.type === 'childList') {
|
|
144
144
|
mutation.addedNodes.forEach(function (node) {
|
|
145
145
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
146
146
|
if (node.hasAttribute && node.getAttribute('auto-accessible') === 'true') {
|
|
147
147
|
updateAccessibilityLabel(node);
|
|
148
148
|
}
|
|
149
149
|
const accessibleElements = node.querySelectorAll
|
|
150
150
|
? node.querySelectorAll('[auto-accessible="true"]')
|
|
151
151
|
: [];
|
|
152
152
|
accessibleElements.forEach(function (el) {
|
|
153
153
|
updateAccessibilityLabel(el);
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
if (mutation.type === 'attributes' && mutation.attributeName === 'auto-accessible') {
|
|
159
159
|
if (mutation.target.getAttribute('auto-accessible') === 'true') {
|
|
160
160
|
updateAccessibilityLabel(mutation.target);
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
});
|
|
165
165
|
mainObserver.observe(document.body, mainConfig);
|
|
166
166
|
setupGlobalContentObserver();
|
|
167
167
|
const contentConfig = {
|
|
168
168
|
characterData: true,
|
|
169
169
|
childList: true,
|
|
170
170
|
subtree: true,
|
|
171
171
|
};
|
|
172
172
|
const lastUpdateTime = new WeakMap();
|
|
173
173
|
const THROTTLE_DELAY = 2000;
|
|
174
174
|
|
|
175
175
|
function shouldUpdate(element) {
|
|
176
176
|
const now = Date.now();
|
|
177
177
|
const lastTime = lastUpdateTime.get(element);
|
|
178
178
|
if (!lastTime || now - lastTime >= THROTTLE_DELAY) {
|
|
179
179
|
lastUpdateTime.set(element, now);
|
|
180
180
|
return true;
|
|
181
181
|
}
|
|
182
182
|
return false;
|
|
183
183
|
}
|
|
184
184
|
const globalContentObserver = new MutationObserver(function (mutations) {
|
|
185
185
|
const affectedElements = new Set();
|
|
186
186
|
mutations.forEach(function (mutation) {
|
|
187
187
|
let targetElement = null;
|
|
188
188
|
if (mutation.type === 'characterData') {
|
|
189
189
|
targetElement = findClosestAccessibleElement(mutation.target);
|
|
190
190
|
} else if (mutation.type === 'childList') {
|
|
191
191
|
targetElement = findClosestAccessibleElement(mutation.target);
|
|
192
192
|
}
|
|
193
193
|
if (targetElement && targetElement.getAttribute('auto-accessible') === 'true') {
|
|
194
194
|
affectedElements.add(targetElement);
|
|
195
195
|
}
|
|
196
196
|
});
|
|
197
197
|
affectedElements.forEach(function (element) {
|
|
198
198
|
if (shouldUpdate(element)) {
|
|
199
199
|
updateAccessibilityLabel(element);
|
|
200
200
|
} else {
|
|
201
201
|
}
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
204
|
globalContentObserver.observe(document.body, contentConfig);
|
|
205
205
|
let current = node;
|
|
206
206
|
if (current.nodeType === Node.TEXT_NODE) {
|
|
207
207
|
current = current.parentElement;
|
|
208
208
|
}
|
|
209
209
|
while (current && current !== document.body) {
|
|
210
210
|
if (current.getAttribute && current.getAttribute('auto-accessible') === 'true') {
|
|
211
211
|
return current;
|
|
212
212
|
}
|
|
213
213
|
current = current.parentElement;
|
|
214
214
|
}
|
|
215
215
|
return null;
|
|
216
216
|
if (!element) return;
|
|
217
217
|
if (element.hasAttribute('aria-label')) {
|
|
218
218
|
completeA11yAttributes(element);
|
|
219
219
|
if (!element.getAttribute('data-auto-aria-label')) {
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
const text = element.innerText;
|
|
224
224
|
if (text) {
|
|
225
225
|
const processedText = text.replace(/\r|\n/g, ' ').replace(/¥\s(\d+)(\s(\.\d+))?/, '¥$1$3');
|
|
226
226
|
element.setAttribute('aria-label', processedText);
|
|
227
227
|
element.setAttribute('data-auto-aria-label', 'true');
|
|
228
228
|
completeA11yAttributes(element);
|
|
229
229
|
}
|
|
230
230
|
if (!element.hasAttribute('role')) {
|
|
231
231
|
element.setAttribute('role', 'text');
|
|
232
232
|
}
|
|
233
233
|
if (!element.hasAttribute('tabindex')) {
|
|
234
234
|
element.setAttribute('tabindex', 0);
|
|
235
235
|
}
|
|
236
236
|
console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
|
|
237
237
|
setupMainObserver();
|
|
238
238
|
console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);
|