Skip to content

Commit

Permalink
Merge pull request #439 from podium-lib/swap_scope_to_strategy
Browse files Browse the repository at this point in the history
Swap scope to strategy
  • Loading branch information
digitalsadhu authored Nov 4, 2024
2 parents 9b8c4d6 + 2cfa49f commit 4a40bed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/podlet.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const { template } = utils;
* @property {import("@podium/proxy").PodiumProxyOptions} [proxy] - options that can be provided to configure the @podium/proxy instance used by the podlet. See that module for details.
*
* @typedef {{ debug: 'true' | 'false', locale: string, deviceType: string, requestedBy: string, mountOrigin: string, mountPathname: string, publicPathname: string }} PodletContext
* @typedef {{ as?: string | false | null, crossorigin?: string | null | boolean, disabled?: boolean | '' | null, hreflang?: string | false | null, title?: string | false | null, media?: string | false | null, rel?: string | false | null, type?: string | false | null, value: string | false | null, strategy?: "beforeInteractive" | "afterInteractive" | "lazy", scope?: "content" | "fallback" | "all" | "shadow-dom", [key: string]: any }} AssetCssLike
* @typedef {{ value: string | null, crossorigin?: string | null | boolean, type?: string | null | false, integrity?: string | null | false, referrerpolicy?: string | null | false, nomodule?: boolean | null | '', async?: boolean | null | '', defer?: boolean | null | '', data?: {[key: string]: string} | Array<{ key: string; value: string }>, strategy?: "beforeInteractive" | "afterInteractive" | "lazy", scope?: "content" | "fallback" | "all" | "shadow-dom", [key: string]: any }} AssetJsLike
* @typedef {{ as?: string | false | null, crossorigin?: string | null | boolean, disabled?: boolean | '' | null, hreflang?: string | false | null, title?: string | false | null, media?: string | false | null, rel?: string | false | null, type?: string | false | null, value: string | false | null, strategy?: "beforeInteractive" | "afterInteractive" | "lazy" | "shadow-dom", scope?: "content" | "fallback" | "all", [key: string]: any }} AssetCssLike
* @typedef {{ value: string | null, crossorigin?: string | null | boolean, type?: string | null | false, integrity?: string | null | false, referrerpolicy?: string | null | false, nomodule?: boolean | null | '', async?: boolean | null | '', defer?: boolean | null | '', data?: {[key: string]: string} | Array<{ key: string; value: string }>, strategy?: "beforeInteractive" | "afterInteractive" | "lazy" | "shadow-dom", scope?: "content" | "fallback" | "all" | "shadow-dom", [key: string]: any }} AssetJsLike
*/

export default class PodiumPodlet {
Expand Down Expand Up @@ -859,11 +859,11 @@ export default class PodiumPodlet {
);

const styles = this.cssRoute
.filter((css) => css.scope === 'shadow-dom')
.filter((css) => css.strategy === 'shadow-dom')
.map((css) => css.toHTML());

const scripts = this.jsRoute
.filter((js) => js.scope === 'shadow-dom')
.filter((js) => js.strategy === 'shadow-dom')
.map((js) => js.toHTML());

// Wrap the markup in DSD.
Expand Down
8 changes: 4 additions & 4 deletions tests/podlet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ tap.test(
);

tap.test(
'useShadowDOM - css assets with shadow-dom scope - should render link tags inside shadow DOM',
'useShadowDOM - css assets with shadow-dom strategy - should render link tags inside shadow DOM',
async (t) => {
const options = {
...DEFAULT_OPTIONS,
Expand All @@ -2107,7 +2107,7 @@ tap.test(
};

const podlet = new Podlet(options);
podlet.css({ value: '/foo', scope: 'shadow-dom' });
podlet.css({ value: '/foo', strategy: 'shadow-dom' });

const server = new FakeExpressServer(podlet, (req, res) => {
res.podiumSend('<h1>OK!</h1>');
Expand All @@ -2125,7 +2125,7 @@ tap.test(
);

tap.test(
'useShadowDOM - css assets with all scope - should not render link tags inside shadow DOM',
'useShadowDOM - css assets with no strategy - should not render link tags inside shadow DOM',
async (t) => {
const options = {
...DEFAULT_OPTIONS,
Expand All @@ -2134,7 +2134,7 @@ tap.test(
};

const podlet = new Podlet(options);
podlet.css({ value: '/foo', scope: 'all' });
podlet.css({ value: '/foo' });

const server = new FakeExpressServer(podlet, (req, res) => {
res.podiumSend('<h1>OK!</h1>');
Expand Down

0 comments on commit 4a40bed

Please sign in to comment.