cbrewster programming blog

Adventures in GSoC 1

During the last week, I worked on implementing the [HTMLConstructor] WebIDL extended attribute.

Pull Requests:

Blog Posts

Overview

According to my roadmap, I will have the custom element portion of the create an element steps implemented by the end of this next week.

I began working on implementing the steps according to the spec, but I ran into issues at Step 6.1.2. The call to Construct was failing for every custom element constructor that I tried. A javascript exception was always thrown at the line in the constructor that calls the superclass’s constructor.

class CustomElement extends HTMLElement {
    constructor() {
        super(); // Error: Invalid constructor.
    }
}

customElements.define('custom-element', CustomElement);

I scratched my head at this issue, as the spec is clear that the superclass’s constructor must be called once in the subclass’s constructor. I consulted with other Servo developers on IRC. I found out that HTML elements don’t have a constructor exposed to JS; therefore, the call to the superclass’s (HTMLElement in this case) fails because the HTMLElement interface does not expose a constructor.

When Custom Elements were added to the spec, special constructors were added to certain HTML elements via the [HTMLConstructor] extended attribute.

Before I could begin work on implementing custom elements in document.createElement, I had to implement HTMLConstructor.

Next Steps

During this week I finished the first pass at the implementation and plan to have it polished and merged by the middle of this next week.

Once merged, I will finish the work on implementing the create an element steps by the end of this next week.