all files / lib/src/instance/methods/ clean.js

6.25% Statements 1/16
0% Branches 0/4
0% Functions 0/2
6.25% Lines 1/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                                                 
import { each } from '../../utils/generic'
import { getNodes, logger } from '../../utils/core'
import rinse from '../functions/rinse'
 
 
export default function clean (target) {
	var this$1 = this;
 
 
	var dirty
	try {
		each(getNodes(target), function (node) {
			var id = node.getAttribute('data-sr-id')
			if (id !== null) {
				dirty = true
				node.setAttribute('style', this$1.store.elements[id].styles.inline)
				node.removeAttribute('data-sr-id')
				delete this$1.store.elements[id]
			}
		})
	} catch (e) {
		return logger.call(this, 'Clean failed.', e.message)
	}
 
	if (dirty) {
		try {
			rinse.call(this)
		} catch (e) {
			return logger.call(this, 'Clean failed.', 'Rinse failed.', e.message)
		}
	}
}