Skip to content

Commit

Permalink
fixed #11
Browse files Browse the repository at this point in the history
  • Loading branch information
easylogic committed Aug 4, 2020
1 parent 88ffff0 commit ccde9c4
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 11 deletions.
33 changes: 30 additions & 3 deletions dist/sapa.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,20 @@ class Dom {
return null;
}

static createFragment (htmlString) {
var div = Dom.create('div');
return Dom.create(div.html(htmlString).createChildrenFragment())
static createBySVG (svgString) {

var list = Dom.createByHTML(`<svg>${svgString}</svg>`).children();

if (list.length) {
return Dom.create(list[0].el);
}

return null;
}

static createFragment (domString, containerTag = 'div') {
var div = Dom.create(containerTag);
return Dom.create(div.html(domString).createChildrenFragment())
}

static getScrollTop() {
Expand Down Expand Up @@ -980,6 +991,14 @@ class Dom {
return $dom;
}

prependSVG(html) {
var $dom = Dom.create("div").html(`<svg>${html}</svg>`);

this.prepend($dom.$('svg').createChildrenFragment());

return $dom;
}

appendHTML(html) {
var $dom = Dom.create("div").html(html);

Expand All @@ -988,6 +1007,14 @@ class Dom {
return $dom;
}

appendSVG(html) {
var $dom = Dom.create("div").html(`<svg>${html}</svg>`);

this.append($dom.$('svg').createChildrenFragment());

return $dom;
}

/**
* create document fragment with children dom
*/
Expand Down
35 changes: 31 additions & 4 deletions dist/sapa.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.sapa = {}));
(global = global || self, factory(global.sapa = {}));
}(this, (function (exports) { 'use strict';

function debounce (callback, delay = 0) {
Expand Down Expand Up @@ -753,9 +753,20 @@
return null;
}

static createFragment (htmlString) {
var div = Dom.create('div');
return Dom.create(div.html(htmlString).createChildrenFragment())
static createBySVG (svgString) {

var list = Dom.createByHTML(`<svg>${svgString}</svg>`).children();

if (list.length) {
return Dom.create(list[0].el);
}

return null;
}

static createFragment (domString, containerTag = 'div') {
var div = Dom.create(containerTag);
return Dom.create(div.html(domString).createChildrenFragment())
}

static getScrollTop() {
Expand Down Expand Up @@ -986,6 +997,14 @@
return $dom;
}

prependSVG(html) {
var $dom = Dom.create("div").html(`<svg>${html}</svg>`);

this.prepend($dom.$('svg').createChildrenFragment());

return $dom;
}

appendHTML(html) {
var $dom = Dom.create("div").html(html);

Expand All @@ -994,6 +1013,14 @@
return $dom;
}

appendSVG(html) {
var $dom = Dom.create("div").html(`<svg>${html}</svg>`);

this.append($dom.$('svg').createChildrenFragment());

return $dom;
}

/**
* create document fragment with children dom
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@easylogic/sapa",
"version": "0.1.0",
"version": "0.1.1",
"description": "Simple JS Application Library",
"main": "dist/sapa.js",
"module": "dist/sapa.esm.js",
Expand Down
33 changes: 30 additions & 3 deletions src/util/Dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,20 @@ export class Dom {
return null;
}

static createFragment (htmlString) {
var div = Dom.create('div')
return Dom.create(div.html(htmlString).createChildrenFragment())
static createBySVG (svgString) {

var list = Dom.createByHTML(`<svg>${svgString}</svg>`).children()

if (list.length) {
return Dom.create(list[0].el);
}

return null;
}

static createFragment (domString, containerTag = 'div') {
var div = Dom.create(containerTag)
return Dom.create(div.html(domString).createChildrenFragment())
}

static getScrollTop() {
Expand Down Expand Up @@ -276,6 +287,14 @@ export class Dom {
return $dom;
}

prependSVG(html) {
var $dom = Dom.create("div").html(`<svg>${html}</svg>`);

this.prepend($dom.$('svg').createChildrenFragment());

return $dom;
}

appendHTML(html) {
var $dom = Dom.create("div").html(html);

Expand All @@ -284,6 +303,14 @@ export class Dom {
return $dom;
}

appendSVG(html) {
var $dom = Dom.create("div").html(`<svg>${html}</svg>`);

this.append($dom.$('svg').createChildrenFragment());

return $dom;
}

/**
* create document fragment with children dom
*/
Expand Down

0 comments on commit ccde9c4

Please sign in to comment.