Sha256: 977db0fa2be36467ecf910776c166e1e59024b9ffc01f9c522cadb140e2aa9f2

Contents?: true

Size: 532 Bytes

Versions: 4

Compression:

Stored size: 532 Bytes

Contents

import Node from '../Node.js';

const hasDashes = val => /-/.test(val);

const formatKey = key => (hasDashes(key) ? `'${key}'` : key);

const formatVal = val => (val ? '' : 'true');

export default class JSXAttribute extends Node {
	transpile(code, transforms) {
		const { start, name } = this.name;

		// Overwrite equals sign if value is present.
		const end = this.value ? this.value.start : this.name.end;

		code.overwrite(start, end, `${formatKey(name)}: ${formatVal(this.value)}`);

		super.transpile(code, transforms);
	}
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jass-0.9.5 vendor/node_modules/buble/src/program/types/JSXAttribute.js
jass-0.9.4 vendor/node_modules/buble/src/program/types/JSXAttribute.js
jass-0.9.3 vendor/node_modules/buble/src/program/types/JSXAttribute.js
jass-0.9.1 vendor/node_modules/buble/src/program/types/JSXAttribute.js