Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Hyper fast diffing algorithm for real DOM nodes :zap:
var morph = require('nanomorph')
var html = require('bel')
var tree = html`<div>hello people</div>`
tree = morph(tree, html`<div>nanananana-na-no</div>`)
tree = morph(tree, html`<div>teeny, tiny, tin bottle</div>`)
var update = require('nanomorph/update')
var html = require('bel')
// create the initial tree, save it and append to DOM
var tree = html`<div>hello people</div>`
var morph = update(tree)
document.body.appendChild(tree)
// now each consecutive update will be rendered on the DOM
morph(html`<div>hello people</div>`, tree)
// even if the type of the root node changes
morph(html`<p>nanananana-na-no</p>`, tree)
Sometimes we want to tell the algorithm to not evaluate certain nodes (and its
children). This can be because we're sure they haven't changed, or perhaps
because another piece of code is managing that part of the DOM tree. To achieve
this nanomorph
evaluates the .isSameNode()
method on nodes to determine if
they should be updated or not.
var el = html`<div>node</div>`
// tell nanomorph to not compare the DOM tree if they're both divs
el.isSameNode = function (target) {
return (target && target.nodeName && target.nodeName === 'DIV')
}
Nanomorph was optimized for simplicity, but different situations might require different tradeoffs. So in order to allow folks to build their own implementation we expose our test suite as a function you can call. So regardless if you're doing it to solve a problem, or just for fun: you can use the same tests we use for your own implementation. Yay! :sparkles:
var test = require('nanomorph/test')
test(require('./my-morph-implementation'))
Diff a tree of HTML elements against another tree of HTML elements and create a patched result that can be applied on the DOM.
Create a diffing function that morphs one tree into another, even if the type of the root node changes
Diff the previous tree with a new tree using the function returned from
update()
:warning: nanomorph will modify the newTree and it should be discarded after use
$ npm install nanomorph
FAQs
Hyper fast diffing algorithm for real DOM nodes
The npm package nanomorph receives a total of 1,067 weekly downloads. As such, nanomorph popularity was classified as popular.
We found that nanomorph demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 29 open source maintainers 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.