Created
March 6, 2024 18:10
-
-
Save thonerohh/62cdc4fbd54fa721c2848ec4c110a267 to your computer and use it in GitHub Desktop.
W3 feature proposal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have found some useful function and want to move it forward. | |
It is bad that I was not able to put object between files and so I was adde= | |
d some addictive addons for such simple function. `const targetPlace =3D do= | |
cument.querySelector(place);` I was interested to move directly object to '= | |
document.SOMEDATA.innerHTML', but it was occurred as an error. | |
So Assembler have only MOVE ambition, so it is generally better for W3 to s= | |
trict it's ability. | |
// move object to place | |
async function moveHTMLContent(place, object) { | |
try { | |
const pagePattern =3D await loadHTMLContent(object); | |
const targetPlace =3D document.querySelector(place); | |
if (pagePattern) { | |
if (targetPlace) { | |
targetPlace.innerHTML =3D pagePattern; | |
} else { | |
console.error('Target element not found for selector:', selector); | |
} | |
} else { | |
console.error('Page pattern content not loaded for step number:', ste= | |
pNumber); | |
} | |
} catch (error) { | |
console.error('Error updating page content:', error); | |
} | |
} | |
// load object | |
async function loadHTMLContent(url) { | |
try { | |
const response =3D await fetch(url); | |
if (!response.ok) { | |
throw new Error(`HTTP error! status: ${response.status}`); | |
} | |
return await response.text(); // assuming the content is text/HTML | |
} catch (error) { | |
console.error("Could not load HTML content:", error); | |
return null; | |
} | |
} | |
Wish best regards, | |
Rohh Thone. | |
Tell me please where are I need to move this message? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment