@conecli/cone-render 0.10.1-shop3.45 → 0.10.1-shop3.46
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 -0
- package/dist/common/accessibility.ts +0 -0
- package/dist/common/index.h5.ts +1 -1
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/sass/app.h5.scss +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro';
|
|
2
|
'app-activity',
|
|
1
3
|
'app-rank',
|
|
2
4
|
'app-seckill',
|
|
3
5
|
'm-coupon',
|
|
4
6
|
'scene-buy',
|
|
5
7
|
if (window?.shopGlobalSwitch?.openAccessibilityLanguage) {
|
|
6
8
|
Taro.nextTick(() => {
|
|
7
9
|
const htmlRoot = document?.documentElement;
|
|
8
10
|
htmlRoot && htmlRoot.setAttribute('lang', isLanguageForEn ? 'en' : 'zh-CN');
|
|
9
11
|
});
|
|
10
12
|
}
|
|
11
13
|
const mainConfig = {
|
|
12
14
|
childList: true,
|
|
13
15
|
subtree: true,
|
|
14
16
|
attributes: true,
|
|
15
17
|
attributeFilter: ['auto-accessible'],
|
|
16
18
|
};
|
|
17
19
|
const mainObserver = new MutationObserver(function (mutations) {
|
|
18
20
|
mutations.forEach(function (mutation) {
|
|
19
21
|
if (mutation.type === 'childList') {
|
|
20
22
|
mutation.addedNodes.forEach(function (node) {
|
|
21
23
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
22
24
|
if (node.hasAttribute && node.getAttribute('auto-accessible') === 'true') {
|
|
23
25
|
updateAccessibilityLabel(node);
|
|
24
26
|
}
|
|
25
27
|
const accessibleElements = node.querySelectorAll
|
|
26
28
|
? node.querySelectorAll('[auto-accessible="true"]')
|
|
27
29
|
: [];
|
|
28
30
|
accessibleElements.forEach(function (el) {
|
|
29
31
|
updateAccessibilityLabel(el);
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
if (mutation.type === 'attributes' && mutation.attributeName === 'auto-accessible') {
|
|
35
37
|
if (mutation.target.getAttribute('auto-accessible') === 'true') {
|
|
36
38
|
updateAccessibilityLabel(mutation.target);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
});
|
|
40
42
|
});
|
|
41
43
|
mainObserver.observe(document.body, mainConfig);
|
|
42
44
|
setupGlobalContentObserver();
|
|
43
45
|
const contentConfig = {
|
|
44
46
|
characterData: true,
|
|
45
47
|
childList: true,
|
|
46
48
|
subtree: true,
|
|
47
49
|
};
|
|
48
50
|
const lastUpdateTime = new WeakMap();
|
|
49
51
|
const THROTTLE_DELAY = 2000;
|
|
50
52
|
|
|
51
53
|
function shouldUpdate(element) {
|
|
52
54
|
const now = Date.now();
|
|
53
55
|
const lastTime = lastUpdateTime.get(element);
|
|
54
56
|
if (!lastTime || now - lastTime >= THROTTLE_DELAY) {
|
|
55
57
|
lastUpdateTime.set(element, now);
|
|
56
58
|
return true;
|
|
57
59
|
}
|
|
58
60
|
return false;
|
|
59
61
|
}
|
|
60
62
|
const globalContentObserver = new MutationObserver(function (mutations) {
|
|
61
63
|
const affectedElements = new Set();
|
|
62
64
|
mutations.forEach(function (mutation) {
|
|
63
65
|
let targetElement = null;
|
|
64
66
|
if (mutation.type === 'characterData') {
|
|
65
67
|
targetElement = findClosestAccessibleElement(mutation.target);
|
|
66
68
|
} else if (mutation.type === 'childList') {
|
|
67
69
|
targetElement = findClosestAccessibleElement(mutation.target);
|
|
68
70
|
}
|
|
69
71
|
if (targetElement && targetElement.getAttribute('auto-accessible') === 'true') {
|
|
70
72
|
affectedElements.add(targetElement);
|
|
71
73
|
}
|
|
72
74
|
});
|
|
73
75
|
affectedElements.forEach(function (element) {
|
|
74
76
|
if (shouldUpdate(element)) {
|
|
75
77
|
updateAccessibilityLabel(element);
|
|
76
78
|
} else {
|
|
77
79
|
}
|
|
78
80
|
});
|
|
79
81
|
});
|
|
80
82
|
globalContentObserver.observe(document.body, contentConfig);
|
|
81
83
|
let current = node;
|
|
82
84
|
if (current.nodeType === Node.TEXT_NODE) {
|
|
83
85
|
current = current.parentElement;
|
|
84
86
|
}
|
|
85
87
|
while (current && current !== document.body) {
|
|
86
88
|
if (current.getAttribute && current.getAttribute('auto-accessible') === 'true') {
|
|
87
89
|
return current;
|
|
88
90
|
}
|
|
89
91
|
current = current.parentElement;
|
|
90
92
|
}
|
|
91
93
|
return null;
|
|
92
94
|
if (!element) return;
|
|
93
95
|
if (element.hasAttribute('aria-label')){
|
|
94
96
|
completeA11yAttributes(element);
|
|
95
97
|
if(!element.getAttribute('data-auto-aria-label')) {
|
|
96
98
|
return;
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
const text = element.innerText;
|
|
100
102
|
if (text) {
|
|
101
103
|
const processedText = text.replace(/\r|\n/g, ' ').replace(/¥\s(\d+)(\s(\.\d+))?/, '¥$1$3');
|
|
102
104
|
element.setAttribute('aria-label', processedText);
|
|
103
105
|
element.setAttribute('data-auto-aria-label', 'true');
|
|
104
106
|
completeA11yAttributes(element);
|
|
105
107
|
}
|
|
106
108
|
if (!element.hasAttribute('role')) {
|
|
107
109
|
element.setAttribute('role', 'text');
|
|
108
110
|
}
|
|
109
111
|
if (!element.hasAttribute('tabindex')) {
|
|
110
112
|
element.setAttribute('tabindex', 0);
|
|
111
113
|
}
|
|
112
114
|
console.log('🚀 ~~ 页面启用无障碍自动支持方案 ~~ buildType:', buildType);
|
|
113
115
|
setupMainObserver();
|
|
114
116
|
console.log('🚀 ~~ 页面不启用无障碍自动支持方案 !! buildType:', buildType);
|
|
File without changes
|