9b5086d649
Implement a serialization "generator" for `DOMElement` in domutils.js that yields the serialization of the SVG element. This method is used by a newly added `ReadableSVGStream` class, which can be used like any other readable stream in Node.js. This reduces the memory requirements. Now, it is not needed to require the serialization to fully fit in memory. Note: The implementation of the serializer is a state machine in ES5 since the rest of the file is also in ES5. Its functionality is equivalent to: ``` function* serializeSVGElement(elem) { yield '<' + elem.nodeName; if (elem.nodeName === 'svg:svg') { yield ' xmlns:xlink="http://www.w3.org/1999/xlink"' + ' xmlns:svg="http://www.w3.org/2000/svg"'; } for (let i in elem.attributes) { yield ' ' + i + '="' + xmlEncode(elem.attributes[i]) + '"'; } yield '>'; if (elem.nodeName === 'svg:tspan' || elem.nodeName === 'svg:style') { yield xmlEncode(elem.textContent); } else { for (let childNode of elem.childNodes) { yield* serializeSVGElement(childNode); } } yield '</' + elem.nodeName + '>'; } ``` |
||
---|---|---|
.. | ||
acroforms | ||
browserify | ||
components | ||
helloworld | ||
learning | ||
mobile-viewer | ||
node | ||
svgviewer | ||
text-only | ||
webpack |