Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else {
try {
var html = JSON.parse(stdout);
} catch(e) {
html = 'Parsing error: ' + e;
}
// PhantomJS output
console.log(html);
// template render function
reqHandler(res, html);
}
});
// if ph == false (default) -> jsDom
} else {
jsdom.env(data.toString(), function (err, win) {
// jsdom.env(publicPath + '/' + urlPath, function (err, win) { // url mode
if (err) res.end('JSdom report error:\n ' + err);
else {
console.log('JSDOM', wrap);
var
doc = win.document,
html = {};
try {
html.title = doc.title;
html.meta = dom.getMeta(doc);
html.styles = dom.getHeadData(doc)[0];
html.scripts = dom.getHeadData(doc)[1];
html.source = dom.getSource(doc, id, wrap);
} catch (e) {
html.err = {
function parse_pages(info_page, sessions_page, callback) {
if (typeof callback === 'undefined') {
callback = function (err, infos) {};
}
info_page = utils.gb2312_to_utf8(info_page);
sessions_page = utils.gb2312_to_utf8(sessions_page);
var infos = {};
// Parse info page.
jsdom.env(info_page, function (err, window) {
if (err) {
console.error('Error while parsing usereg user page: %s', err);
callback(err);
return false;
} else {
// Parse data pairs.
var all_infos = {};
var data = window.document.getElementsByClassName('maintd');
for (var i = 1; i < data.length; i += 2)
all_infos[data[i-1].textContent.trim()] = data[i].textContent.trim();
infos.usage = Number(/\d+/.exec(all_infos["使用流量(IPV4)"])[0]);
infos.balance = Number(/\d+\.\d+/.exec(all_infos["帐户余额"])[0]);
}
});
var parseSpec = function(sections, pathToSpec) {
var deferred = Q.defer();
// Parsing spec with JSdom
jsdom.env(
'http://127.0.0.1:' + global.opts.core.server.port + pathToSpec + '?internal=true',
['http://127.0.0.1:' + global.opts.core.server.port + '/source/assets/js/modules/sectionsParser.js'],
function (err, window) {
if (err) {
deferred.reject({
err: err,
msg: 'JSDOM error'
});
return;
}
var output = {};
var SourceGetSections = window.SourceGetSections;
var parser = new SourceGetSections();
var jsdom = require("jsdom");
var fs = require("fs");
var jalangi = !!process.argv[2];
var scripts = jalangi ? ['../../../src/js/analysis.js', '../../../src/js/InputManager.js', '../../../node_modules/escodegen/escodegen.browser.js', '../../../node_modules/esprima/esprima.js', '../../../src/js/utils/astUtil.js', '../../../src/js/instrument/esnstrument.js', '../jquery-2.0.2_jalangi_.js'] : ['../jquery-2.0.2.js'];
jsdom.env(
'',
scripts,
function (errors, window) {
var markup = window.jQuery(
"<div><div><p><span><b class="\"a\"">b</b></span></p></div></div>"
),
path = "";
var tmp1 = markup.find("*");
console.log(tmp1.length);
debugger;
var tmp2 = tmp1.filter("b");
console.log(tmp2.length);
markup.remove();
function createDOM(done) {
jsdom.env(
'',
["http://code.jquery.com/jquery.js"],
function (err, window) {
global.document = window.document;
global.window = window;
global.$ = window.jQuery;
done();
}
);
}
const targets = process.argv.slice(2).map(target => target.split(':'));
const prefixes = {
cjs: 'module.exports = ',
es: 'export default '
};
const comment = `/**
* This file was automatically generated from \`build.js\`.
* Do not manually edit.
*/
`;
jsdom.env('https://html.spec.whatwg.org/multipage/syntax.html', (err, window) => {
if (err) {
throw err;
}
const document = window.document;
const codes = document.querySelector('dfn#void-elements')
.parentNode
.nextElementSibling
.textContent
.replace(/\s/gm,'')
.split(",")
.reduce((obj, code) => {
obj[code] = true;
return obj;
}, {});
for (const [file, format = 'cjs'] of targets) {
return new Promise((resolve,reject)=>jsdom.env(source,[],(err,window)=>err&&reject(err)||resolve(window.document.querySelectorAll(selector))));
}
return new Promise((resolve, reject) => {
env(html, [], (error, window) => {
if (error) {
return reject(error);
}
return resolve(window);
});
});
}
self.status = "fetching";
if (cache[self.url]) {
var cached = cache[self.url];
self.title = cached.title;
self.links = cached.links;
self.favicon = cached.favicon;
self.validate();
self.grapher.addPages(self.links, self.url);
self.status = "fetched";
callback();
return;
}
jsdom.env(self.url, [
globals.JQUERY_URI
],
function(errors, window) {
if (!errors) {
window.$("a[rel~=me]").each(function (i, elem) {
if (elem.href.substring(0,1) !== '/') {
self.links.push(elem.href);
}
});
self.title = window.document.title;
self.resolveFavicon(window);
self.validate();
self.grapher.addPages(self.links, self.url);
self.status = "fetched";