Socket
Socket
Sign inDemoInstall

jssoup

Package Overview
Dependencies
1
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.6 to 0.0.7

51

dist/lib/jssoup.js

@@ -20,3 +20,2 @@ 'use strict';

try {
console.log(navigator.platform);
htmlparser = Tautologistics.NodeHtmlParser;

@@ -284,3 +283,7 @@ } catch (e) {}

} else {
text += this.contents[i]._prettify(indent, breakline, level + 1);
if (this.contents[i] instanceof SoupComment) {
text += indent.repeat(level + 1) + "<!--" + this.contents[i]._text + "-->" + breakline;
} else {
text += this.contents[i]._prettify(indent, breakline, level + 1);
}
}

@@ -350,17 +353,2 @@ }

}
//* descendants () {
//var cur = this.nextElement;
//while (cur) {
//var parent = cur.parent;
//while (parent && parent != this) {
//parent = parent.parent;
//}
//if (!parent) break;
//yield cur;
//cur = cur.nextElement;
//}
//return undefined;
//}
}, {

@@ -427,5 +415,14 @@ key: 'descendants',

if (typeof attrs == 'string' || Array.isArray(attrs)) {
if (typeof attrs == 'string') {
attrs = { class: [attrs] };
} else if (Array.isArray(attrs)) {
attrs = { class: attrs };
} else if (attrs && attrs.class && typeof attrs.class == 'string') {
attrs.class = [attrs.class];
}
if (attrs && attrs.class) {
for (var i = 0; i < attrs.class.length; ++i) {
attrs.class[i] = attrs.class[i].trim();
}
}
this.name = name;

@@ -458,3 +455,3 @@ this.attrs = attrs;

for (var i = 0; i < props.length; ++i) {
if (props[i] in tag.attrs && this._matchAttrs(tag.attrs[props[i]], this.attrs[props[i]])) {
if (props[i] in tag.attrs && this._matchAttrs(props[i], tag.attrs[props[i]], this.attrs[props[i]])) {
found = true;

@@ -485,12 +482,16 @@ break;

key: '_matchAttrs',
value: function _matchAttrs(candidateAttrs, attrs) {
value: function _matchAttrs(name, candidateAttrs, attrs) {
if (typeof candidateAttrs == 'string') {
if (name == 'class') {
candidateAttrs = candidateAttrs.replace(/\s\s+/g, ' ').trim().split(' ');
} else {
candidateAttrs = [candidateAttrs];
}
}
if (typeof attrs == 'string') {
attrs = [attrs];
}
if (typeof candidateAttrs == 'string') {
candidateAttrs = [candidateAttrs];
for (var i = 0; i < attrs.length; ++i) {
if (candidateAttrs.indexOf(attrs[i]) < 0) return false;
}
for (var i = 0; i < candidateAttrs.length; ++i) {
if (attrs.indexOf(candidateAttrs[i]) < 0) return false;
}
return true;

@@ -497,0 +498,0 @@ }

{
"name": "jssoup",
"version": "0.0.6",
"description": "JSSoup is a BeautifulSopu style HTML parser library.",
"version": "0.0.7",
"description": "JSSoup is a BeautifulSoup style HTML parser library.",
"main": "./dist/lib/jssoup.js",

@@ -6,0 +6,0 @@ "files": [

@@ -37,2 +37,23 @@ JSSoup

```
### Name
```javascript
var soup = new JSSoup('<html><head>hello</head></html>');
var tag = soup.find('head');
tag.name
// 'head'
tag.name = 'span'
console.log(tag)
//<span>hello</span>
```
### Attributes
```javascript
var soup = new JSSoup('<tag id="hi" class="banner">hello</tag>');
var tag = soup.nextElement;
tag.attrs
// {id: 'hi', class: 'banner'}
tag.attrs.id = 'test';
console.log(tag)
// <tag id="test" class="banner">hello</tag>
```
### Navigation

@@ -39,0 +60,0 @@ #### .previousElement, .nextElement

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc