<commit_before>'use strict';

var isCallable = require('es5-ext/lib/Object/is-callable')
  , isAttr     = require('../../Attr/is-attr')
  , element    = require('../valid-element');

module.exports = function (name, value) {
	element(this);
	if (value == null) {
		this.removeAttribute(name);
		this[name] = null;
	} else if (typeof value === 'string') {
		this.setAttribute(name, value);
	} else if (isCallable(value)) {
		this.setAttribute(name, name);
		this[name] = value;
	} else if (typeof value === 'boolean') {
		if (value) {
			this.setAttribute(name, name);
			this[name] = true;
		} else {
			this.removeAttribute(name);
			this[name] = false;
		}
	} else if (isCallable(value.toDOMAttr)) {
		this.setAttribute(value.toDOMAttr(this, name));
	} else if (isAttr(value)) {
		// Deprecated
		this.setAttributeNode(value);
	} else {
		this.setAttribute(name, value);
	}
};<commit_msg>Fix toDOMAttr handling<commit_after>'use strict';

var isCallable = require('es5-ext/lib/Object/is-callable')
  , isAttr     = require('../../Attr/is-attr')
  , element    = require('../valid-element');

module.exports = function (name, value) {
	element(this);
	if (value == null) {
		this.removeAttribute(name);
		this[name] = null;
	} else if (typeof value === 'string') {
		this.setAttribute(name, value);
	} else if (isCallable(value)) {
		this.setAttribute(name, name);
		this[name] = value;
	} else if (typeof value === 'boolean') {
		if (value) {
			this.setAttribute(name, name);
			this[name] = true;
		} else {
			this.removeAttribute(name);
			this[name] = false;
		}
	} else if (isCallable(value.toDOMAttr)) {
		value.toDOMAttr(this, name);
	} else if (isAttr(value)) {
		// Deprecated
		this.setAttributeNode(value);
	} else {
		this.setAttribute(name, value);
	}
};
{'fraction_non_alphanumeric': 0.18022598870056497, 'fraction_numerical': 0.0011299435028248588, 'mean_word_length': 3.8125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '808815', 'n_tokens_mistral': 667, 'n_tokens_neox': 627, 'n_words': 126}