Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions nx2/blocks/feedback/feedback.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LitElement, html, nothing } from 'da-lit';
import { getConfig } from '../../scripts/nx.js';
import { loadStyle } from '../../utils/utils.js';
import { loadFragment } from '../fragment/fragment.js';
import '../shared/menu/menu.js';

const { codeBase } = getConfig();
Expand Down Expand Up @@ -92,9 +91,14 @@ class NxFeedback extends LitElement {
}

async _loadItems() {
const fragment = await loadFragment(FEEDBACK_PATH);
if (!fragment) return;
this._items = parseFeedbackItems(fragment);
// Parse directly, not via loadFragment: loadArea's icon decorator 404s
// on nonexistent S2_Icon_* SVGs, and we discard its DOM work anyway.
const resp = await fetch(FEEDBACK_PATH);
if (!resp.ok) return;
const doc = new DOMParser().parseFromString(await resp.text(), 'text/html');
const main = doc.querySelector('main');
if (!main) return;
this._items = parseFeedbackItems(main);
}

_handleSelect({ detail: { id } }) {
Expand Down
8 changes: 4 additions & 4 deletions nx2/test/unit/nx/blocks/feedback/feedback.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect } from '@esm-bundle/chai';
import { setConfig } from '../../../../../scripts/nx.js';

// fragment.js (a transitive dependency of feedback.js) captures getConfig()
// into a module-level constant at import time, so setConfig() must resolve
// before feedback.js is ever imported — a static import would evaluate (and
// freeze that constant) before this file's own top-level code could run.
// feedback.js captures getConfig() into a module-level constant at import
// time (for ICON_HREF), so setConfig() must resolve before feedback.js is
// ever imported — a static import would evaluate (and freeze that constant)
// before this file's own top-level code could run.
await setConfig({ hostnames: [] });
const { parseFeedbackItems } = await import('../../../../../blocks/feedback/feedback.js');

Expand Down
Loading