Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(jqLite): Adding more support for custom element tagnames #10619

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function camelCase(name) {

var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/;
var HTML_REGEXP = /<|&#?\w+;/;
var TAG_NAME_REGEXP = /<([\w:]+)/;
var TAG_NAME_REGEXP = /<([\w:-]+)/;
var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi;

var wrapMap = {
Expand Down
41 changes: 41 additions & 0 deletions test/jqLiteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,47 @@ describe('jqLite', function() {
});


it('should allow construction of an html element containing dashes', function() {
var nodes;
nodes = jqLite('<my-foo></my-foo>');
expect(nodes.length).toEqual(1);
expect(nodes[0].nodeName).toEqual('MY-FOO');

nodes = jqLite('<my-foo />');
expect(nodes.length).toEqual(1);
expect(nodes[0].nodeName).toEqual('MY-FOO');
});


it('should allow construction of an html element containing dashes and starting with characters that match existing html elements', function() {
var nodes;

nodes = jqLite('<option-foo></option-foo>');
expect(nodes.length).toEqual(1);
expect(nodes[0].nodeName).toEqual('OPTION-FOO');

nodes = jqLite('<thead-foo></thead-foo>');
expect(nodes.length).toEqual(1);
expect(nodes[0].nodeName).toEqual('THEAD-FOO');

nodes = jqLite('<col-foo></col-foo>');
expect(nodes.length).toEqual(1);
expect(nodes[0].nodeName).toEqual('COL-FOO');

nodes = jqLite('<tr-foo></tr-foo>');
expect(nodes.length).toEqual(1);
expect(nodes[0].nodeName).toEqual('TR-FOO');

nodes = jqLite('<td-foo></td-foo>');
expect(nodes.length).toEqual(1);
expect(nodes[0].nodeName).toEqual('TD-FOO');

nodes = jqLite('<div-foo></div-foo>');
expect(nodes.length).toEqual(1);
expect(nodes[0].nodeName).toEqual('DIV-FOO');
});


it('should allow construction of html with leading whitespace', function() {
var nodes = jqLite(' \n\r \r\n<div>1</div><span>2</span>');
expect(nodes[0].parentNode).toBeDefined();
Expand Down