UNPKG

shadow-function

Version:

ioing lib - shadow Function, worker Function

105 lines (92 loc) 2.62 kB
import { Sandbox, ShadowFunction, ShadowDocument, ShadowZepto, WorkerFunction, Strongbox, safeEval, jsonp, csp } from '../src/index' // test window.seval = safeEval window.Sandbox = Sandbox window.ShadowFunction = ShadowFunction window.WorkerFunction = WorkerFunction window.ShadowDocument = ShadowDocument // window.ShadowPreact = ShadowPreact window.Strongbox = Strongbox Sandbox.debugger('I know the danger!') // ShadowFunction.debugger('I know the danger!') // new ShadowDocument(document.body, '<div><div id="dd">123</div></div>', [{}, {}])( // ` // mtop.apply({dd:66}).then(() => { // console.log(this, 877) // }).then(() => { // console.log(this, 877) // }) // console.log(mtop) // function aa (e) { // this.Function = () =>{ console.log(98) } // console.log(this, e, 5555) // } // window.addEventListener('click', aa, false) // // window.removeEventListener('click', aa, false) // window.document.getElementById('dd').addEventListener('click', function () { // console.log(21212121) // }, false) // ` // )({ // aa: { // ss: 88 // }, // cc: function () { // }, // mtop: function () { // let yy = new Promise((resolve, reject) => { // setTimeout(resolve, 3000) // }) // return yy // } // }) new ShadowZepto(` 'use strict'; let $box = $('#app') $box.html('<img src="https://img.alicdn.com/tfs/TB1APImyyLaK1RjSZFxXXamPFXa-1080-720.jpg">') let $img = $box.find('img') // $box.click((e) => { // console.log(e.y, 888) // $box.find('img').attr('src', './assets/image/2.png') // }) $box[0].addEventListener('touchmove', function (e) { e.uu = 998787 console.log(e.touches[0].clientX, e.target, ww) }) console.log(doc.body.style.background = "#000") `, { // DOM 节点权限设置 'DIV': true, 'P': true, 'BUTTON': true, 'IMG': function (name, value) { // if (name === 'src' && value === 'https://img.alicdn.com/tfs/TB1APImyyLaK1RjSZFxXXamPFXa-1080-720.jpg') { return true // } } })({ // 赋予内部的对象 console, ww: window, location: window.location, doc: document, alert: function (str) { alert('alert 允许执行: ' + str) }, setTimeout: function (fn, t) { console.log(t) setTimeout(function () { console.log(t, 776) fn() }, t) }, setInterval: function (fn, t) { let i = 0 let tid = setInterval(function () { fn() i++ }, t) setTimeout(function () { console.log('1s pReact 循环异步执行渲染了' + i + '张图片和按钮事件绑定') clearTimeout(tid) }, 1000) } })