Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
@doars/doars-morph
Advanced tools
Doars plugin that adds a morph context and directive that instead of setting directly to the innerHTML of an element morphs the DOM to the new structure.
Plugin that adds a morph context and directive which instead of setting directly to the innerHTML of an element morphs the DOM to the new structure.
Install the package from NPM, then import and enable the library in your build.
npm i @doars/doars @doars/doars-morph
// Import library.
import Doars from '@doars/doars'
import DoarsMorph from '@doars/doars-morph'
// Setup a library instance.
const doars = new Doars()
// Setup the plugin.
const doarsMorph = DoarsMorph(doars /*, options */)
// Enable library.
doars.enable()
Add the IIFE build to the page from for example the jsDelivr CDN and enable the library.
<!-- Import library. -->
<script src="https://cdn.jsdelivr.net/npm/@doars/doars@2/dst/doars.iife.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@doars/doars-morph@2/dst/doars-morph.iife.js"></script>
<script type="application/javascript">
document.addEventListener('DOMContentLoaded', () => {
// Setup a library instance.
const doars = new window.Doars()
// Setup the plugin.
const doarsMorph = window.DoarsMorph(doars /*, options */)
// Enable library.
doars.enable()
})
</script>
ESM and IIFE builds are also available via the jsDelivr CDN.
The following directives are added by the plugin.
{Boolean} decode = false
If the returned type is a string the value will's special HTML characters will be decoded. For example >
will become >
.<!-- Morph the inner HTML of the element to the string. -->
<div d-morph="'<h1>Hello world!</h1>'"></div>
<!-- Decodes the special HTML characters before morphing the inner HTML of the element to the string. -->
<div d-morph.decode="'<h1>Hello world!</h1>'"></div>
<!-- Morph the outer HTML of the element, changing this element in the process. -->
<div d-html.outer="'<h1>Hello world!</h1>'"></div>
<!-- Morph the inner HTML of the element to a value from the state. -->
<div d-morph="$state.message"></div>
constructor
Create plugin instance.
@param {Doars} library
A doars library instance.@returns {DoarsMorph}
disable
Disables the plugin. Can only be called when the doars is disabled.enable
Enables the plugin. Can only be called when the doars is disabled.@doars/doars-morph version | @doars/doars version |
---|---|
2.x | 2.x |
FAQs
Doars plugin that adds a morph context and directive that instead of setting directly to the innerHTML of an element morphs the DOM to the new structure.
The npm package @doars/doars-morph receives a total of 1 weekly downloads. As such, @doars/doars-morph popularity was classified as not popular.
We found that @doars/doars-morph demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.