@mzzsfy/dsh-settings-nav-icons 0.4.0 → 0.4.2
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/README.md +4 -0
- package/package.json +1 -1
- package/src/client.js +6 -0
- package/test/orchestration.test.mjs +3 -0
package/README.md
CHANGED
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -16,6 +16,8 @@ window.__ModuleLoader__.load({
|
|
|
16
16
|
factory(require) {
|
|
17
17
|
// ---- 官方 DOM 字面量标识(设置弹窗导航,CSS Modules 哈希前缀稳定) ----
|
|
18
18
|
|
|
19
|
+
// 注册 id 单点定义:样式 data-plugin 标记与装载归属同源,防字面量双写漂移
|
|
20
|
+
const PLUGIN_ID = '@mzzsfy/dsh-settings-nav-icons'
|
|
19
21
|
const SELECTOR_CELL = 'button.VOzbGW_navCell'
|
|
20
22
|
const SELECTOR_LABEL = '.VOzbGW_navLabel'
|
|
21
23
|
const ATTR_MARK = 'data-navic'
|
|
@@ -268,6 +270,8 @@ window.__ModuleLoader__.load({
|
|
|
268
270
|
|
|
269
271
|
function installOverlayStyle() {
|
|
270
272
|
overlayStyle = document.createElement('style')
|
|
273
|
+
// 自带 data-plugin:缺失时宿主 claimStyles 会把它归属给后续材质化插件,其 HMR 重建即误删
|
|
274
|
+
overlayStyle.setAttribute('data-plugin', PLUGIN_ID)
|
|
271
275
|
overlayStyle.textContent = OVERLAY_CSS
|
|
272
276
|
document.head.appendChild(overlayStyle)
|
|
273
277
|
if (slot !== null) slot.overlayStyle = overlayStyle
|
|
@@ -825,6 +829,8 @@ window.__ModuleLoader__.load({
|
|
|
825
829
|
|
|
826
830
|
function installScrollStyle() {
|
|
827
831
|
scrollStyle = document.createElement('style')
|
|
832
|
+
// 自带 data-plugin:缺失时宿主 claimStyles 会把它归属给后续材质化插件,其 HMR 重建即误删
|
|
833
|
+
scrollStyle.setAttribute('data-plugin', PLUGIN_ID)
|
|
828
834
|
scrollStyle.textContent = NAVLIST_SCROLL_CSS
|
|
829
835
|
document.head.appendChild(scrollStyle)
|
|
830
836
|
if (slot !== null) slot.scrollStyle = scrollStyle
|
|
@@ -143,6 +143,8 @@ function fakeDocument() {
|
|
|
143
143
|
value: '',
|
|
144
144
|
placeholder: '',
|
|
145
145
|
innerHTML: '',
|
|
146
|
+
attrs: {},
|
|
147
|
+
setAttribute(name, value) { el.attrs[name] = value },
|
|
146
148
|
appendChild(child) { el.children.push(child) },
|
|
147
149
|
focus() { el.focused = true },
|
|
148
150
|
addEventListener(type, fn) { el.handlers[type] = fn },
|
|
@@ -250,6 +252,7 @@ test('启动样式:覆盖浮层样式与滚动样式注入 head,卸载移除,重
|
|
|
250
252
|
assert.equal(doc.createdStyles.length, 2, '恰两次注入(浮层+滚动)')
|
|
251
253
|
assert.ok(doc.createdStyles.some((el) => el.textContent.includes('sni-ov')), '浮层样式随启动注入')
|
|
252
254
|
assert.ok(doc.createdStyles.some((el) => el.textContent === NAVLIST_SCROLL_CSS), '滚动规则与实现同源')
|
|
255
|
+
assert.ok(doc.createdStyles.every((el) => el.attrs['data-plugin'] === '@mzzsfy/dsh-settings-nav-icons'), '样式自带 data-plugin,防宿主 claimStyles 误归属后随他插件 HMR 整批误删')
|
|
253
256
|
assert.equal(doc.head.children.length, 2, '样式挂载在 head')
|
|
254
257
|
assert.deepEqual(doc.events, ['style', 'style', 'observe'], '样式注入先于观察器挂载')
|
|
255
258
|
unload()
|