Skip to content

Commit 4a51d8a

Browse files
authored
Merge pull request #15 from puzzle-js/cihadhoruzoglu-patch-1
Cihadhoruzoglu patch 1
2 parents 60bbe2a + 6947268 commit 4a51d8a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@puzzle-js/client-lib",
33
"main": "dist/index.js",
4-
"version": "1.3.2",
4+
"version": "1.3.3",
55
"author": "<emre.kul@trendyol.com>",
66
"license": "MIT",
77
"repository": {

src/core.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export class Core extends Module {
169169
if (!key.startsWith('$')) {
170170
const container = document.querySelector(this.getFragmentContainerSelector(fragment, key));
171171
if (container) {
172-
this.setEvalInnerHtml(container, res[key]);
172+
this.setEvalInnerHtml(container, res[key],container.tagName === "meta");
173173
}
174174
}
175175
});
@@ -180,7 +180,7 @@ export class Core extends Module {
180180
}
181181

182182
private static getFragmentContainerSelector(fragment: IPageFragmentConfig, partial: string) {
183-
return partial === "main" ? `[puzzle-fragment="${fragment.name}"]` : `[puzzle-fragment="${fragment.name}"][fragment-partial="${partial}"]`;
183+
return partial === "main" ? `[puzzle-fragment="${fragment.name}"]:not([fragment-partial])` : `[puzzle-fragment="${fragment.name}"][fragment-partial="${partial}"]`;
184184
}
185185

186186
private static prepareQueryString(fragmentAttributes: Record<string, string>) {
@@ -195,7 +195,12 @@ export class Core extends Module {
195195
return Object.keys(attributes).reduce((query: string, key: string) => `${query}&${key}=${attributes[key]}`, '?__renderMode=stream');
196196
}
197197

198-
private static setEvalInnerHtml(elm: any, html: any) {
198+
private static setEvalInnerHtml(elm: any, html: any, meta?: boolean) {
199+
if(meta){
200+
elm.outerHTML = html;
201+
return;
202+
}
203+
199204
elm.innerHTML = html;
200205
Array.from(elm.querySelectorAll("script")).forEach((oldScript: any) => {
201206
const newScript = document.createElement("script");

0 commit comments

Comments
 (0)