This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
generated from HugoDF/microbundle-ts-pkg
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(strip-microbundle-add-render-load)
- `load` function - async function that loads components from files given a file path - `render` function - sync function that renders a component given a HTML string - option to override `x-data` - attaches all `__x` properties on the returned component
- Loading branch information
Showing
17 changed files
with
899 additions
and
2,875 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div x-data="" name="component-1"></div> | ||
<div x-data="" name="component-2"></div> | ||
<div x-data="" name="component-3"></div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div x-data="" name="component-1"></div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div x-data="{ foo: 'bar' }"> | ||
<span x-text="foo"></span> | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div x-data="<? echo "{ foo: 'bar' }" ?>"> | ||
<span x-text="foo"></span> | ||
</div> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// @ts-check | ||
const {JSDOM} = require('jsdom'); | ||
|
||
/** | ||
* Override Node.js `global` using passed `override` object. | ||
* | ||
* @param {object} override - Override object | ||
* @returns {void} | ||
*/ | ||
function setGlobal(override) { | ||
Object.assign(global, override); | ||
} | ||
|
||
/** | ||
* Set `navigator` global. | ||
* | ||
* @param {Navigator} navigator | ||
* @returns {void} | ||
*/ | ||
function setNavigator(navigator) { | ||
setGlobal({ | ||
navigator | ||
}); | ||
} | ||
|
||
/** | ||
* Set `MutationObserver` global. | ||
* | ||
* @param {Function} mutationObserver | ||
* @returns {void} | ||
*/ | ||
function setMutationObserver(mutationObserver) { | ||
setGlobal({ | ||
MutationObserver: mutationObserver | ||
}); | ||
} | ||
|
||
/** | ||
* Pre-Alpine.start() setup work. | ||
*/ | ||
function config() { | ||
// These need to happen before Alpine.js loads | ||
// otherwise it tries to start() itself, | ||
// since "isTesting" returns false. | ||
setNavigator(new JSDOM().window.navigator); | ||
setMutationObserver( | ||
class { | ||
observe() {} | ||
} | ||
); | ||
} | ||
|
||
module.exports = { | ||
setGlobal, | ||
setNavigator, | ||
setMutationObserver, | ||
config | ||
}; |
Oops, something went wrong.