Rename ItemPaneHeader CE localName to item-pane-header

Closes #4114
This commit is contained in:
windingwind 2024-05-14 15:32:50 +08:00 committed by Dan Stillman
parent 1e3ebc082e
commit 9a23031c12
6 changed files with 25 additions and 25 deletions

View file

@ -60,7 +60,7 @@ Services.scriptloader.loadSubScript('chrome://zotero/content/elements/itemPaneSe
['zoterosearchcondition', 'chrome://zotero/content/elements/zoteroSearch.js'], ['zoterosearchcondition', 'chrome://zotero/content/elements/zoteroSearch.js'],
['zoterosearchtextbox', 'chrome://zotero/content/elements/zoteroSearch.js'], ['zoterosearchtextbox', 'chrome://zotero/content/elements/zoteroSearch.js'],
['zoterosearchagefield', 'chrome://zotero/content/elements/zoteroSearch.js'], ['zoterosearchagefield', 'chrome://zotero/content/elements/zoteroSearch.js'],
['pane-header', 'chrome://zotero/content/elements/itemPaneHeader.js'], ['item-pane-header', 'chrome://zotero/content/elements/itemPaneHeader.js'],
['editable-text', 'chrome://zotero/content/elements/editableText.js'], ['editable-text', 'chrome://zotero/content/elements/editableText.js'],
['item-pane-sidenav', 'chrome://zotero/content/elements/itemPaneSidenav.js'], ['item-pane-sidenav', 'chrome://zotero/content/elements/itemPaneSidenav.js'],
['abstract-box', 'chrome://zotero/content/elements/abstractBox.js'], ['abstract-box', 'chrome://zotero/content/elements/abstractBox.js'],

View file

@ -317,7 +317,7 @@
if (splitter.getAttribute('state') != 'collapsed') { if (splitter.getAttribute('state') != 'collapsed') {
if (this.mode == "item") { if (this.mode == "item") {
let header = this._itemPaneDeck.selectedPanel.querySelector("pane-header editable-text"); let header = this._itemPaneDeck.selectedPanel.querySelector("item-pane-header editable-text");
header.focus(); header.focus();
return true; return true;
} }

View file

@ -47,7 +47,7 @@
content = MozXULElement.parseXULToFragment(` content = MozXULElement.parseXULToFragment(`
<hbox id="zotero-view-item-container" class="zotero-view-item-container" flex="1"> <hbox id="zotero-view-item-container" class="zotero-view-item-container" flex="1">
<html:div class="zotero-view-item-main"> <html:div class="zotero-view-item-main">
<pane-header id="zotero-item-pane-header" /> <item-pane-header id="zotero-item-pane-header" />
<html:div id="zotero-view-item" class="zotero-view-item" tabindex="0"> <html:div id="zotero-view-item" class="zotero-view-item" tabindex="0">
<item-box id="zotero-editpane-item-box" data-pane="info"/> <item-box id="zotero-editpane-item-box" data-pane="info"/>

View file

@ -381,7 +381,7 @@
}); });
} }
} }
customElements.define("pane-header", ItemPaneHeader); customElements.define("item-pane-header", ItemPaneHeader);
/** /**
* Simple LRU cache that stores bibliography entries for the 100 most recently viewed items. * Simple LRU cache that stores bibliography entries for the 100 most recently viewed items.

View file

@ -1,4 +1,4 @@
pane-header { item-pane-header {
&:not([hidden]) { &:not([hidden]) {
display: flex; display: flex;
} }

View file

@ -63,18 +63,18 @@ describe("Item pane", function () {
it("should be hidden when set to None mode", async function () { it("should be hidden when set to None mode", async function () {
Zotero.Prefs.set('itemPaneHeader', 'none'); Zotero.Prefs.set('itemPaneHeader', 'none');
await createDataObject('item', itemData); await createDataObject('item', itemData);
assert.isTrue(doc.querySelector('pane-header').hidden); assert.isTrue(doc.querySelector('item-pane-header').hidden);
}); });
it("should show title when set to Title mode", async function () { it("should show title when set to Title mode", async function () {
Zotero.Prefs.set('itemPaneHeader', 'title'); Zotero.Prefs.set('itemPaneHeader', 'title');
let item = await createDataObject('item', itemData); let item = await createDataObject('item', itemData);
assert.isFalse(doc.querySelector('pane-header .title').hidden); assert.isFalse(doc.querySelector('item-pane-header .title').hidden);
assert.isTrue(doc.querySelector('pane-header .creator-year').hidden); assert.isTrue(doc.querySelector('item-pane-header .creator-year').hidden);
assert.isTrue(doc.querySelector('pane-header .bib-entry').hidden); assert.isTrue(doc.querySelector('item-pane-header .bib-entry').hidden);
assert.equal(doc.querySelector('pane-header .title editable-text').value, item.getField('title')); assert.equal(doc.querySelector('item-pane-header .title editable-text').value, item.getField('title'));
}); });
it("should show title/creator/year when set to Title/Creator/Year mode", async function () { it("should show title/creator/year when set to Title/Creator/Year mode", async function () {
@ -83,12 +83,12 @@ describe("Item pane", function () {
item.setField('date', '1962-05-01'); item.setField('date', '1962-05-01');
await item.saveTx(); await item.saveTx();
assert.isTrue(doc.querySelector('pane-header .bib-entry').hidden); assert.isTrue(doc.querySelector('item-pane-header .bib-entry').hidden);
assert.isFalse(doc.querySelector('pane-header .title').hidden); assert.isFalse(doc.querySelector('item-pane-header .title').hidden);
assert.isFalse(doc.querySelector('pane-header .creator-year').hidden); assert.isFalse(doc.querySelector('item-pane-header .creator-year').hidden);
assert.equal(doc.querySelector('pane-header .title editable-text').value, item.getField('title')); assert.equal(doc.querySelector('item-pane-header .title editable-text').value, item.getField('title'));
let creatorYearText = doc.querySelector('pane-header .creator-year').textContent; let creatorYearText = doc.querySelector('item-pane-header .creator-year').textContent;
assert.include(creatorYearText, 'Hyde'); assert.include(creatorYearText, 'Hyde');
assert.include(creatorYearText, '1962'); assert.include(creatorYearText, '1962');
}); });
@ -98,11 +98,11 @@ describe("Item pane", function () {
Zotero.Prefs.set('itemPaneHeader.bibEntry.style', 'http://www.zotero.org/styles/apa'); Zotero.Prefs.set('itemPaneHeader.bibEntry.style', 'http://www.zotero.org/styles/apa');
await createDataObject('item', itemData); await createDataObject('item', itemData);
assert.isFalse(doc.querySelector('pane-header .bib-entry').hidden); assert.isFalse(doc.querySelector('item-pane-header .bib-entry').hidden);
assert.isTrue(doc.querySelector('pane-header .title').hidden); assert.isTrue(doc.querySelector('item-pane-header .title').hidden);
assert.isTrue(doc.querySelector('pane-header .creator-year').hidden); assert.isTrue(doc.querySelector('item-pane-header .creator-year').hidden);
let bibEntry = doc.querySelector('pane-header .bib-entry').shadowRoot.firstElementChild.textContent; let bibEntry = doc.querySelector('item-pane-header .bib-entry').shadowRoot.firstElementChild.textContent;
assert.equal(bibEntry.trim(), 'Hyde, G. E. (n.d.). Birds—A Primer of Ornithology (Teach Yourself Books).'); assert.equal(bibEntry.trim(), 'Hyde, G. E. (n.d.). Birds—A Primer of Ornithology (Teach Yourself Books).');
}); });
@ -111,7 +111,7 @@ describe("Item pane", function () {
Zotero.Prefs.set('itemPaneHeader.bibEntry.style', 'http://www.zotero.org/styles/apa'); Zotero.Prefs.set('itemPaneHeader.bibEntry.style', 'http://www.zotero.org/styles/apa');
let item = await createDataObject('item', itemData); let item = await createDataObject('item', itemData);
let bibEntryElem = doc.querySelector('pane-header .bib-entry').shadowRoot.firstElementChild; let bibEntryElem = doc.querySelector('item-pane-header .bib-entry').shadowRoot.firstElementChild;
assert.equal(bibEntryElem.textContent.trim(), 'Hyde, G. E. (n.d.). Birds—A Primer of Ornithology (Teach Yourself Books).'); assert.equal(bibEntryElem.textContent.trim(), 'Hyde, G. E. (n.d.). Birds—A Primer of Ornithology (Teach Yourself Books).');
@ -139,7 +139,7 @@ describe("Item pane", function () {
Zotero.Prefs.set('itemPaneHeader.bibEntry.style', 'http://www.zotero.org/styles/apa'); Zotero.Prefs.set('itemPaneHeader.bibEntry.style', 'http://www.zotero.org/styles/apa');
await createDataObject('item', itemData); await createDataObject('item', itemData);
let bibEntryElem = doc.querySelector('pane-header .bib-entry').shadowRoot.firstElementChild; let bibEntryElem = doc.querySelector('item-pane-header .bib-entry').shadowRoot.firstElementChild;
assert.equal(bibEntryElem.textContent.trim(), 'Hyde, G. E. (n.d.). Birds—A Primer of Ornithology (Teach Yourself Books).'); assert.equal(bibEntryElem.textContent.trim(), 'Hyde, G. E. (n.d.). Birds—A Primer of Ornithology (Teach Yourself Books).');
@ -152,7 +152,7 @@ describe("Item pane", function () {
Zotero.Prefs.set('itemPaneHeader.bibEntry.style', 'http://www.zotero.org/styles/apa'); Zotero.Prefs.set('itemPaneHeader.bibEntry.style', 'http://www.zotero.org/styles/apa');
await createDataObject('item', itemData); await createDataObject('item', itemData);
let bibEntryElem = doc.querySelector('pane-header .bib-entry').shadowRoot.firstElementChild; let bibEntryElem = doc.querySelector('item-pane-header .bib-entry').shadowRoot.firstElementChild;
assert.equal(bibEntryElem.textContent.trim(), 'Hyde, G. E. (n.d.). Birds—A Primer of Ornithology (Teach Yourself Books).'); assert.equal(bibEntryElem.textContent.trim(), 'Hyde, G. E. (n.d.). Birds—A Primer of Ornithology (Teach Yourself Books).');
@ -165,9 +165,9 @@ describe("Item pane", function () {
Zotero.Prefs.set('itemPaneHeader.bibEntry.style', 'http://www.zotero.org/styles/an-id-that-does-not-match-any-citation-style'); Zotero.Prefs.set('itemPaneHeader.bibEntry.style', 'http://www.zotero.org/styles/an-id-that-does-not-match-any-citation-style');
await createDataObject('item', itemData); await createDataObject('item', itemData);
assert.isTrue(doc.querySelector('pane-header .bib-entry').hidden); assert.isTrue(doc.querySelector('item-pane-header .bib-entry').hidden);
assert.isFalse(doc.querySelector('pane-header .title').hidden); assert.isFalse(doc.querySelector('item-pane-header .title').hidden);
assert.isFalse(doc.querySelector('pane-header .creator-year').hidden); assert.isFalse(doc.querySelector('item-pane-header .creator-year').hidden);
}); });
}); });