Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
dom-serialize
Advanced tools
Readme
It's like outerHTML
, but it works with:
For custom serialization logic, a "serialize" event is dispatched on
every Node
which event listeners can override the default behavior on by
setting the event.detail.serialize
property to a String or other Node.
The "serialize" event bubbles, so it could be a good idea to utilize
event delegation on a known root node that will be serialized.
Check the event.serializeTarget
property to check which Node
is
currently being serialized.
$ npm install dom-serialize
var serialize = require('dom-serialize');
var node;
// works with Text nodes
node = document.createTextNode('foo & <bar>');
console.log(serialize(node));
// works with DOM elements
node = document.createElement('body');
node.appendChild(document.createElement('strong'));
node.firstChild.appendChild(document.createTextNode('hello'));
console.log(serialize(node));
// custom "serialize" event
node.firstChild.addEventListener('serialize', function (event) {
event.detail.serialize = 'pwn';
}, false);
console.log(serialize(node));
// you can also just pass a function in for a one-time serializer
console.log(serialize(node, function (event) {
if (event.serializeTarget === node.firstChild) {
// for the first child, output an ellipsis to summarize "content"
event.detail.serialze = '…';
} else if (event.serializeTarget !== node) {
// any other child
event.preventDefault();
}
}));
foo & <bar>
<body><strong>hello</strong></body>
<body>pwn</body>
<body>…</body>
FAQs
Serializes any DOM node into a String
The npm package dom-serialize receives a total of 1,938,752 weekly downloads. As such, dom-serialize popularity was classified as popular.
We found that dom-serialize 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
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.