Commit 8833a0fc authored by David Sveningsson's avatar David Sveningsson

feat(meta): implicit inheritance when overriding existing element

parent 80a07988
......@@ -39,3 +39,5 @@ When inheriting you can still override any properties from the inherited element
For instance <code>&lt;input&gt;</code> is a <code>void</code> element but custom elements cannot be pure <code>void</code> thus if you inherit from it you must set <code>void</code> to <code>false</code>.
</p>
</div>
Inheritance is implied when overwriting existing elements, e.g. when overwriting builtin elements or loading multiple definitions of the same component.
......@@ -406,6 +406,29 @@ describe("MetaTable", () => {
);
});
it("should be implied when a previous element of the same name exists", () => {
expect.assertions(1);
const table = new MetaTable();
table.loadFromObject({
foo: {
flow: true,
},
});
table.loadFromObject({
foo: {
phrasing: true,
},
});
const foo = table.getMetaFor("foo");
expect(foo).toEqual(
expect.objectContaining({
tagName: "foo",
flow: true,
phrasing: true,
})
);
});
it("should allow overriding", () => {
expect.assertions(1);
const table = new MetaTable();
......
......@@ -178,7 +178,7 @@ export class MetaTable {
private addEntry(tagName: string, entry: MetaData): void {
const defaultEntry = {};
let parent = {};
let parent = this.elements[tagName] || {};
/* handle inheritance */
if (entry.inherit) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment