mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 13:13:37 +08:00
This also adds Python-2.0 to the list of accepted licenses. Lastly, it fixes a bug where the package.json files were incorrectly reordered. For the `exports` of a particular package, the order that the entrypoints are defined in is crucial. Therefore, we should not alter the order of entrypoints and instead maintain the originally defined ordering. We can use an `OrderedDict` to ensure that Python always loads the JSON files in the same order. DISABLE_THIRD_PARTY_CHECK=NPM update R=jacktfranklin@chromium.org Bug: none Change-Id: I5a309782de6015edea6ba3b502aa0db1f008d973 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2692909 Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
dom-serialize
Serializes any DOM node into a String
It's like outerHTML, but it works with:
- DOM elements
- Text nodes
- Attributes
- Comment nodes
- Documents
- DocumentFragments
- Doctypes
- NodeLists / Arrays
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.
Installation
$ npm install dom-serialize
Example
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>