Skip to content

Commit

Permalink
fix(engine): closes #486 to lowercase tag names (#494)
Browse files Browse the repository at this point in the history
* fix(engine): closes #486 to lowercase tag names

* fix(engine): PR 494 feedback
  • Loading branch information
caridy authored Jul 11, 2018
1 parent 17133c6 commit 704422f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/lwc-engine/src/3rdparty/polymer/outer-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getInnerHTML } from "./inner-html";
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
const escapeAttrRegExp = /[&\u00A0"]/g;
const escapeDataRegExp = /[&\u00A0<>]/g;
const replace = String.prototype.replace;
const { replace, toLowerCase } = String.prototype;

function escapeReplace(c) {
switch (c) {
Expand Down Expand Up @@ -75,15 +75,15 @@ export function getOuterHTML(node: Node): string {
switch (node.nodeType) {
case Node.ELEMENT_NODE: {
const { tagName, attributes: attrs } = node as Element;
let s = '<' + tagName;
let s = '<' + toLowerCase.call(tagName);
for (let i = 0, attr; (attr = attrs[i]); i++) {
s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
}
s += '>';
if (voidElements.has(tagName)) {
return s;
}
return s + getInnerHTML(node) + '</' + tagName + '>';
return s + getInnerHTML(node) + '</' + toLowerCase.call(tagName) + '>';
}
case Node.TEXT_NODE: {
const { data, parentNode } = node as Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ describe('DOM inspection', () => {
describe('#innerHTML', () => {
it('should implement elm.innerHTML shadow dom semantics', () => {
const p = getHostShadowRoot(element).querySelector('x-parent');
expect(p.innerHTML).toBe('<DIV class=\"first\">Passed Text</DIV>');
expect(getHostShadowRoot(p).querySelector('div').innerHTML).toBe('Before[<SLOT name=\"\"></SLOT>]After');
expect(p.innerHTML).toBe('<div class=\"first\">Passed Text</div>');
expect(getHostShadowRoot(p).querySelector('div').innerHTML).toBe('Before[<slot name=\"\"></slot>]After');
});
});

describe('#outerHTML', () => {
it('should implement elm.outerHTML shadow dom semantics', () => {
const p = getHostShadowRoot(element).querySelector('x-parent');
expect(p.outerHTML).toBe('<X-PARENT><DIV class=\"first\">Passed Text</DIV></X-PARENT>');
expect(getHostShadowRoot(p).querySelector('div').outerHTML).toBe('<DIV class=\"portal\">Before[<SLOT name=\"\"></SLOT>]After</DIV>');
expect(p.outerHTML).toBe('<x-parent><div class=\"first\">Passed Text</div></x-parent>');
expect(getHostShadowRoot(p).querySelector('div').outerHTML).toBe('<div class=\"portal\">Before[<slot name=\"\"></slot>]After</div>');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ describe('custom element text content', () => {
});

it('should return correct innerHTML', function () {
assert.equal(browser.getText('p'), '<DIV>Slot</DIV>');
assert.equal(browser.getText('p'), '<div>Slot</div>');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ describe('custom element text content', () => {
});

it('should return correct innerHTML', function () {
assert.equal(browser.getText('p'), '<X-CHILD><DIV>Slot</DIV></X-CHILD>');
assert.equal(browser.getText('p'), '<x-child><div>Slot</div></x-child>');
});
});

0 comments on commit 704422f

Please sign in to comment.