Skip to content

Commit

Permalink
Added more slot helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
InDIOS committed Oct 31, 2018
1 parent 2e3ddef commit d9a5110
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
_$removeChild, _$isType, _$noop, _$componentUpdate, _$bindClasses, _$bindStyle, _$forLoop,
_$destroyComponent, _$setElements, _$conditionalUpdate, _$emptyElse, _$htmlUpdate, _$addChild,
_$each, _$bindBooleanAttr, _$setReference, _$isKey, _$textUpdate, _$tagUpdate, _$removeReference,
_$toString, _$bindUpdate, _$emptySlot,
_$toString, _$bindUpdate, _$emptySlot, _$appendToSlot, _$declareSlots
} from './utilities';
import {
_$select, _$docFragment, _$append, _$assignEl, _$removeEl, _$getAttr, _$addListener,
Expand All @@ -12,7 +12,7 @@ import {
} from './dom';

export {
_$bindUpdate, _$comment, _$setElements, _$emptySlot,
_$bindUpdate, _$comment, _$setElements, _$emptySlot, _$appendToSlot, _$declareSlots,
_$updateMultiSelect, _$componentUpdate, _$htmlUpdate, _$tagUpdate, _$bindBooleanAttr,
_$removeReference, _$addChild, _$textUpdate, _$getValue, _$text, _$conditionalUpdate,
_$noop, _$toString, _$setReference, _$isType, _$isKey, _$select, _$docFragment, _$append,
Expand Down
8 changes: 7 additions & 1 deletion src/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PROP_MAP } from './constants';
import { _$toArgs, _$List } from './list';
import { _$el, _$getAttr, _$setAttr, _$select, _$assignEl, _$removeEl, _$docFragment } from './dom';
import { _$el, _$getAttr, _$setAttr, _$select, _$assignEl, _$removeEl, _$docFragment, _$append } from './dom';

function _$toLowerCase(str: string) {
return str.toLowerCase();
Expand Down Expand Up @@ -176,6 +176,12 @@ export function _$emptySlot(inst: Component, slot: string) {
let slots = inst.$slots;
return slots[slot] && !slots[slot].hasChildNodes() ? (slots[slot] = _$docFragment()) : null;
}
export function _$appendToSlot(slots: ObjectLike<DocumentFragment>, slot: string, el: HTMLElement) {
!slots[slot].firstChild && _$append(<any>slots[slot], el);
}
export function _$declareSlots($slots: ObjectLike<DocumentFragment>, slots: string[]) {
_$each(slots, slot => { $slots[slot] = _$docFragment(); });
}
export function _$bindClasses(value: string | ObjectLike<boolean> | (string | ObjectLike<boolean>)[]) {
let classes = '';
if (_$isString(value)) {
Expand Down

0 comments on commit d9a5110

Please sign in to comment.