Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions glass-easel/src/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,6 @@ export class Element implements NodeCast {
)
}

/* istanbul ignore if */
if (slotMode === SlotMode.Direct) {
throw new Error('nodes inside direct slots should not change slot name.')
}

const slotUpdater = Element._$updateSubtreeSlotNodes(
this.parentNode!,
[this],
Expand Down
5 changes: 0 additions & 5 deletions glass-easel/src/global_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ export type ComponentOptions = {
multipleSlots?: boolean
/** Enable dynamic slots or not */
dynamicSlots?: boolean
/** Enable direct slots or not */
directSlots?: boolean
/** Write property values of components to backend with `setAttribute` */
reflectToAttributes?: boolean
/** Allow properties and methods to be able to visit directly in component instance */
Expand Down Expand Up @@ -93,7 +91,6 @@ export type NormalizedComponentOptions = {
extraStyleScope: StyleScopeId | null
multipleSlots: boolean
dynamicSlots: boolean
directSlots: boolean
reflectToAttributes: boolean
writeFieldsToNode: boolean
writeIdToDOM: boolean
Expand Down Expand Up @@ -135,7 +132,6 @@ export const globalOptions: NormalizedComponentOptions & EnvironmentOptions = {
hostNodeTagName: 'wx-x',
multipleSlots: false,
dynamicSlots: false,
directSlots: false,
reflectToAttributes: false,
writeFieldsToNode: true,
writeIdToDOM: false,
Expand Down Expand Up @@ -171,7 +167,6 @@ export const normalizeComponentOptions = (
extraStyleScope: p.extraStyleScope !== undefined ? p.extraStyleScope : b.extraStyleScope,
multipleSlots: p.multipleSlots !== undefined ? p.multipleSlots : b.multipleSlots,
dynamicSlots: p.dynamicSlots !== undefined ? p.dynamicSlots : b.dynamicSlots,
directSlots: p.directSlots !== undefined ? p.directSlots : b.directSlots,
reflectToAttributes:
p.reflectToAttributes !== undefined ? p.reflectToAttributes : b.reflectToAttributes,
writeFieldsToNode:
Expand Down
18 changes: 2 additions & 16 deletions glass-easel/src/shadow_root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import { VirtualNode } from './virtual_node'
import { ThirdError, triggerWarning } from './warning'

export const enum SlotMode {
Direct = 0,
Single,
Single = 1,
Multiple,
Dynamic,
}
Expand Down Expand Up @@ -97,7 +96,6 @@ export class ShadowRoot extends VirtualNode {
const hostComponentOptions = host.getComponentOptions()
if (hostComponentOptions.multipleSlots) slotMode = SlotMode.Multiple
else if (hostComponentOptions.dynamicSlots) slotMode = SlotMode.Dynamic
else if (hostComponentOptions.directSlots) slotMode = SlotMode.Direct
node._$slotMode = slotMode
if (slotMode === SlotMode.Single) {
node._$singleSlot = null
Expand Down Expand Up @@ -376,7 +374,6 @@ export class ShadowRoot extends VirtualNode {
getSlotElementFromName(name: string): Element | Element[] | null {
const slotMode = this._$slotMode
/* istanbul ignore if */
if (slotMode === SlotMode.Direct) throw new Error('cannot get slot element in directSlots')
if (slotMode === SlotMode.Single) return this._$singleSlot!
if (slotMode === SlotMode.Multiple) {
return this._$slots![name] || null
Expand All @@ -401,7 +398,6 @@ export class ShadowRoot extends VirtualNode {
*/
getContainingSlot(elem: Node | null): Element | null {
const slotMode = this._$slotMode
if (slotMode === SlotMode.Direct) return elem?.containingSlot || null
if (slotMode === SlotMode.Single) return this._$singleSlot as Element | null
if (slotMode === SlotMode.Dynamic) {
if (!elem) return null
Expand Down Expand Up @@ -448,10 +444,6 @@ export class ShadowRoot extends VirtualNode {
*/
forEachSlot(f: (slot: Element) => boolean | void) {
const slotMode = this._$slotMode
/* istanbul ignore if */
if (slotMode === SlotMode.Direct) {
throw new Error('Cannot iterate slots in directSlots')
}
if (slotMode === SlotMode.Single) {
if (this._$singleSlot) f(this._$singleSlot)
} else if (slotMode === SlotMode.Multiple) {
Expand Down Expand Up @@ -621,7 +613,7 @@ export class ShadowRoot extends VirtualNode {
const slotMode = this._$slotMode

// single slot does not care slot name
if (slotMode === SlotMode.Single || slotMode === SlotMode.Direct) return
if (slotMode === SlotMode.Single) return

// for multiple slots, reassign slot contents
if (slotMode === SlotMode.Multiple) {
Expand Down Expand Up @@ -650,9 +642,6 @@ export class ShadowRoot extends VirtualNode {
): void {
const slotMode = this._$slotMode

// for direct slotting, do nothing
if (slotMode === SlotMode.Direct) return

if (slotMode === SlotMode.Single) {
const oldSlot = this._$singleSlot as Element | null
const newSlot = this._$subtreeSlotStart!.value
Expand Down Expand Up @@ -705,9 +694,6 @@ export class ShadowRoot extends VirtualNode {
): void {
const slotMode = this._$slotMode

// for direct slotting, do nothing
if (slotMode === SlotMode.Direct) return

if (slotMode === SlotMode.Single) {
// will call applySLotsInsertion after if slots were moved
// no need to do anything here
Expand Down