sweep-spaces

1.0.1 • Public • Published

sweep-spaces

sweep dom spaces text nodes

Install

npm install sweep-spaces

Usage & Apis

var sweep_spaces = require("sweep-spaces");

var el = document.getElementById('divResult3');

el.innerHTML = `
	<span>aaa</span>	<span>bbb<span>ccc</span>   </span><!--a comment--><!CDATA[a cdata]><br>
	<span id="sp_end">end</span> `;

/*
sweepSpaces(nodeStart [, nodeEnd [, options]])
sweep dom spaces text nodes.
	options:
		.sweepComment
			sweep all comment nodes
		.sweepCdata
			sweep all CDATA sections

return the first existed node
*/
sweep_spaces(el.firstChild, document.getElementById('sp_end'), { sweepComment: true, sweepCdata: true });

done(!(
	el.innerHTML === '<span>aaa</span><span>bbb<span>ccc</span></span><br><span id="sp_end">end</span> '
));

Readme

Keywords

Package Sidebar

Install

npm i sweep-spaces

Weekly Downloads

3

Version

1.0.1

License

ISC

Unpacked Size

4.33 kB

Total Files

4

Last publish

Collaborators

  • adf0001