How to use the ncname.test function in ncname

To help you get started, we’ve selected a few ncname examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github angular / batarang / hint.bundle.js View on Github external
}

	if (name.indexOf('-') === -1) {
		return 'Custom element names must contain a hyphen. Example: unicorn-cake';
	}

	if (/^\d/i.test(name)) {
		return 'Custom element names must not start with a digit.';
	}

	if (/^-/i.test(name)) {
		return 'Custom element names must not start with a hyphen.';
	}

	// http://www.w3.org/TR/custom-elements/#concepts
	if (!ncname.test(name)) {
		return 'Invalid element name.';
	}

	if (reservedNames.indexOf(name) !== -1) {
		return 'The supplied element name is reserved and can\'t be used.\nSee: http://www.w3.org/TR/custom-elements/#concepts';
	}
};

ncname

Regular expression for matching XML NCName

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Popular ncname functions