The following revision refers to this bug:
https://chromium.googlesource.com/chromium/src.git/+/9d82f81d395329a5426d4ee459c2006b25da76b5
commit 9d82f81d395329a5426d4ee459c2006b25da76b5
Author: davaajav <davaajav@google.com>
Date: Wed Jul 06 07:29:29 2016
Added test for step 2, 14 in define element.
Test for step 2.
- Tests cases when HTMLElement, HTMLButtonElement
is passed as constructor. Step 2 should throw
TypeError, but it passes without errors.
- Passing author-defined custom element constructors
created via class extends HTMLElement {} passes
this step without TypeError.
- Passing JavaScript class Set fails during upgrade.
Test for step 14.
- If Type(prototype) is an Object, and connectedCallback
is not defined and not Callable, it throws TypeError.
- If Type(prototype) is an Object, and disconnectedCallback
is not defined and not Callable, it throws TypeError.
- If attributeChangedCallback is not Callable is not
undefined and not Callable, it throws TypeError.
- If any step in the first set of steps in 14 throws,
it rethrows that exception and terminates the
algorithm.
BUG= 594918
Review-Url: https://codereview.chromium.org/2089383003
Cr-Commit-Position: refs/heads/master@{#403862}
[modify] https://crrev.com/9d82f81d395329a5426d4ee459c2006b25da76b5/third_party/WebKit/LayoutTests/custom-elements/spec/define-element.html
We would really like feedback. Please try it! Not everything works yet. Please turn on crash reporting and paste crash IDs (which you can get from chrome://crashes) into comments on this bug if you experience crashes. Feel free to send me email if you have questions. (If there's a ton of questions we'll work out something more scalable.)
Hi,
When i try to get all children of my custom element in a connectedCallback (children can be custom elements), i can get all children when the definitions of custom elements are under HTML, BUT when the defintions are above, i just get normal element Without custom elements.
- Case 1 : KO
#-- custom elements defintions --#
<elmt-container>
<div>1</div>
<elmt-test>2</elmt-test>
</elmt-container>
Result : i just get the first div in the connectedCallback of elmt-container.
JsFiddle: https://jsfiddle.net/mcd7bd82/
- Case 2 : OK
<elmt-container>
<div>1</div>
<elmt-test>2</elmt-test>
</elmt-container>
#-- custom elements defintions --#
result : i get all children in the connectedCallback of elmt-container.
JsFiddle: https://jsfiddle.net/4uw0a7yk/
On Chrome 54, the element is created (logged in the console) but the HTML is not updated. Did I miss something?
<!doctype html>
<html>
<head>
<script>
class Cev1 extends HTMLElement {
constructor ()
{
super()
this.innerHTML = "Hello V1"
console.log( "created this=", this )
}
}
customElements.define( "test-v1", Cev1 )
</script>
</head>
<body>
<test-v1>Avant</test-v1>
</body>
</html>
#60: The spec requires constructors not to add children nor attributes, so your code is failing there. Move "innerHTML" to "connectedCallback".
We should be reporting errors to console in that case though, that part looks like a bug.
Next time, for individual issues, please file a separate bug.
Comment 1 by bugdroid1@chromium.org
, Apr 6 2016