lib/repeater-content.js
function setNodeContent(node, content) {
	// find caret position and replace it with content, if possible
	if (node.value) {
		const ranges = findUnescapedTokens(node.value, caret);
		if (ranges.length) {
			node.value = replaceRanges(node.value, ranges, content);
			return;
		}
	}

	if ((node.name && node.name.toLowerCase() === 'a') || node.hasAttribute('href')) {
		// special case: inserting content into `<a>` tag
		if (reUrl.test(content)) {
			node.setAttribute('href', (reProto.test(content) ? '' : 'http://') + content);
		} else if (reEmail.test(content)) {
			node.setAttribute('href', 'mailto:' + content);
		}
	}

	node.value = content;
}
function setNodeContent(node, content) {
	// find caret position and replace it with content, if possible
	if (node.value) {
		const ranges = findUnescapedTokens(node.value, caret);
		if (ranges.length) {
			node.value = replaceRanges(node.value, ranges, content);
			return;
		}
	}

	if ((node.name && node.name.toLowerCase() === 'a') || node.hasAttribute('href')) {
		// special case: inserting content into `<a>` tag
		if (reUrl.test(content)) {
			node.setAttribute('href', (reProto.test(content) ? '' : 'http://') + content);
		} else if (reEmail.test(content)) {
			node.setAttribute('href', 'mailto:' + content);
		}
	}

	node.value = content;
}
function setNodeContent ( node , content ) { // find caret position and replace it with content, if possible if ( node . value ) { const ranges = findUnescapedTokens ( node . value , caret ) ; if ( ranges . length ) { node . value = replaceRanges ( node . value , ranges , content ) ; return ; } } if ( ( node . name && node . name . toLowerCase ( ) === 'a' ) || node . hasAttribute ( 'href' ) ) { // special case: inserting content into `<a>` tag if ( reUrl . test ( content ) ) { node . setAttribute ( 'href' , ( reProto . test ( content ) ? '' : 'http://' ) + content ) ; } else if ( reEmail . test ( content ) ) { node . setAttribute ( 'href' , 'mailto:' + content ) ; } } node . value = content ; }
Updates content of given node
@param {Node} node
@param {String} content
Updates content of given node