-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This closes #57, closes #52, closes #46, closes #42, closes #36, closes #31, closes #30, closes #28, closes #26, and closes #25.
- Loading branch information
1 parent
77a31c5
commit 509c148
Showing
12 changed files
with
379 additions
and
74 deletions.
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
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,8 @@ | ||
<!doctype html> | ||
<html> | ||
<body> | ||
<meta charset="UTF-8"> | ||
<script type="module" src="test-attribute-changed-errors.js"></script> | ||
<h3>View Console</h3> | ||
</body> | ||
</html> |
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,101 @@ | ||
import XElement from '../x-element.js'; | ||
import { assert, it } from '../../../@netflix/x-test/x-test.js'; | ||
|
||
it('errors are thrown on attribute changed for setting values with bad types', () => { | ||
// We cannot try-catch setAttribute, so we fake the attributeChangedCallback. | ||
class TestElement extends XElement { | ||
static get properties() { | ||
return { | ||
object: { | ||
type: Object, | ||
}, | ||
}; | ||
} | ||
} | ||
customElements.define('test-element-1', TestElement); | ||
const el = new TestElement(); | ||
el.connectedCallback(); | ||
let passed = false; | ||
try { | ||
el.attributeChangedCallback('object', null, '{}'); | ||
} catch (error) { | ||
const expected = 'Unexpected deserialization for "TestElement.properties.object" (cannot deserialize into Object).'; | ||
passed = error.message === expected; | ||
} | ||
assert(passed, 'appropriate error message is thrown'); | ||
}); | ||
|
||
it('errors are thrown on attribute change for read-only properties', () => { | ||
// We cannot try-catch setAttribute, so we fake the attributeChangedCallback. | ||
class TestElement extends XElement { | ||
static get properties() { | ||
return { | ||
readOnly: { | ||
type: String, | ||
readOnly: true, | ||
}, | ||
}; | ||
} | ||
} | ||
customElements.define('test-element-2', TestElement); | ||
const el = new TestElement(); | ||
let passed = false; | ||
el.connectedCallback(); | ||
try { | ||
el.attributeChangedCallback('read-only', null, 'nope'); | ||
} catch (error) { | ||
const expected = 'Property "TestElement.properties.readOnly" is readOnly (element authors may use "internalProperties").'; | ||
passed = error.message === expected; | ||
} | ||
assert(passed, 'appropriate error message is thrown'); | ||
}); | ||
|
||
it('errors are thrown on attribute change for internal properties', () => { | ||
// We cannot try-catch setAttribute, so we fake the attributeChangedCallback. | ||
class TestElement extends XElement { | ||
static get properties() { | ||
return { | ||
internal: { | ||
type: String, | ||
internal: true, | ||
}, | ||
}; | ||
} | ||
} | ||
customElements.define('test-element-3', TestElement); | ||
const el = new TestElement(); | ||
el.connectedCallback(); | ||
let passed = false; | ||
try { | ||
el.attributeChangedCallback('internal', null, 'nope'); | ||
} catch (error) { | ||
const expected = 'Property "TestElement.properties.internal" is internal (element authors may use "internalProperties").'; | ||
passed = error.message === expected; | ||
} | ||
assert(passed, 'appropriate error message is thrown'); | ||
}); | ||
|
||
it('errors are thrown on attribute change for resolved properties', () => { | ||
// We cannot try-catch setAttribute, so we fake the attributeChangedCallback. | ||
class TestElement extends XElement { | ||
static get properties() { | ||
return { | ||
resolved: { | ||
type: String, | ||
resolver: () => {}, | ||
}, | ||
}; | ||
} | ||
} | ||
customElements.define('test-element-4', TestElement); | ||
const el = new TestElement(); | ||
el.connectedCallback(); | ||
let passed = false; | ||
try { | ||
el.attributeChangedCallback('resolved', null, 'nope'); | ||
} catch (error) { | ||
const expected = 'Property "TestElement.properties.resolved" has resolver (cannot be set).'; | ||
passed = error.message === expected; | ||
} | ||
assert(passed, 'appropriate error message is thrown'); | ||
}); |
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
File renamed without changes.
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
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
Oops, something went wrong.