Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Include support for customised built-in elements (#2266)
* Include support for customised built-in elements * Inline the variable declaration
- Loading branch information
1 parent
d439563
commit a311b04
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { createElement, render, Component } from 'preact'; | ||
import { setupScratch, teardown } from '../_util/helpers'; | ||
|
||
/** @jsx createElement */ | ||
|
||
describe('customised built-in elements', () => { | ||
let scratch; | ||
|
||
beforeEach(() => { | ||
scratch = setupScratch(); | ||
}); | ||
|
||
afterEach(() => { | ||
teardown(scratch); | ||
}); | ||
|
||
it('should create built in elements correctly', () => { | ||
class Foo extends Component { | ||
constructor(props) { | ||
super(props); | ||
return true; | ||
} | ||
render() { | ||
return <div is="built-in" />; | ||
} | ||
} | ||
|
||
const spy = sinon.spy(); | ||
|
||
class BuiltIn extends HTMLDivElement { | ||
connectedCallback() { | ||
spy(); | ||
} | ||
} | ||
|
||
customElements.define('built-in', BuiltIn, { extends: 'div' }); | ||
|
||
render(<Foo />, scratch); | ||
|
||
expect(spy).to.have.been.calledOnce; | ||
}); | ||
}); |