@conecli/cone-render 0.10.1-shop3.84 → 0.10.1-shop3.85

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