Skip to content

adf0001/sweep-spaces

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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> '
));

About

sweep dom spaces text nodes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published