Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
stephband committed Jul 28, 2024
1 parent 4a21095 commit d861ad5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 62 deletions.
20 changes: 6 additions & 14 deletions element/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,34 +129,26 @@ export default function LiteralElement(tag, lifecycle = {}, properties = {}) {
},

connect: function(shadow, internals) {
const { renderer } = internals;
const { renderer, object, data } = internals;

if (!internals.initialised) {
internals.initialised = true;

// Get data found in dataset
assignDataset(internals.object, this.dataset);

// Set internal data to object's observer proxy
internals.data = Data.of(internals.object);
}
if (!data) internals.data = Data.of(object);

// We must render synchronously here else rendered 'slotchange'
// listeners miss the first slotchange... this IS synchronous, right?
internals.renderer.push(internals.data);
renderer.push(internals.data);

// Connect callback called post-render
if (lifecycle.connect) lifecycle.connect.call(this, shadow, internals, internals.data);
},

disconnect: function(shadow, internals) {
const { renderer } = internals;
const { renderer, data } = internals;

// Make literal renderer go dormant
internals.renderer.push(null);
renderer.push(null);

// Disconnect callback post render
if (lifecycle.disconnect) lifecycle.disconnect.call(this, shadow, internals, internals.data);
if (lifecycle.disconnect) lifecycle.disconnect.call(this, shadow, internals, data);
},

enable: lifecycle.enable && function enable(shadow, internals) { lifecycle.enable.call(this, shadow, internals, internals.data); },
Expand Down
42 changes: 0 additions & 42 deletions modules/renderer.js

This file was deleted.

12 changes: 6 additions & 6 deletions modules/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Data from '../../fn/modules/data.js';
import create from '../../dom/modules/create.js';
import identify from '../../dom/modules/identify.js';
import { pathSeparator } from './compile/constants.js';
import Renderer, { stats } from './renderer.js';
import Renderer, { stats } from './renderer/renderer.js';
import compileNode from './compile.js';
import { groupCollapsed, groupEnd } from './log.js';

Expand All @@ -43,7 +43,7 @@ const defaults = {};


/*
LiteralRenderer
Literal
Descendant paths are stored in the form `"#id>1>12>3"`, enabling fast
cloning of template instances without retraversing their DOMs looking for
literal attributes and text.
Expand Down Expand Up @@ -96,11 +96,11 @@ export default class Literal {
}

static isTemplate(object) {
return object instanceof LiteralRenderer;
return object instanceof Literal;
}

static of(html) {
return LiteralRenderer.from(create('template', html));
static fromHTML(html) {
return Literal.fromTemplate(create('template', html));
}

static fromFragment(fragment, identifier, element, consts = {}, data, options) {
Expand Down Expand Up @@ -246,7 +246,7 @@ export default class Literal {

// Last node is not in the DOM
if (this.content.lastChild === last) {
throw new Error('Illegal LiteralRenderer.before() – template is not in the DOM');
throw new Error('Illegal Literal.before() – template is not in the DOM');
}

// First node is not in the DOM
Expand Down

0 comments on commit d861ad5

Please sign in to comment.