Socket
Socket
Sign inDemoInstall

angular-html5

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-html5 - npm Package Compare versions

Comparing version 2.2.1 to 2.3.0

1

bin/angular-html5.js

@@ -50,3 +50,2 @@ #!/usr/bin/env node

function readFiles(files) {
//TOOD: handle multiple files
var file = files[0];

@@ -53,0 +52,0 @@ var _contents = fs.readFileSync(path.resolve(process.cwd(), file), 'utf8');

@@ -1,73 +0,2 @@

'use strict';
var cheerio = require('cheerio');
var defaultPrefix = 'ng-';
module.exports = function (params) {
params = params || {};
//find ng-something by default
var customPrefixes = params.customPrefixes || [];
if (customPrefixes && !Array.isArray(customPrefixes)) {
customPrefixes = [customPrefixes];
}
var prefixes = [defaultPrefix].concat(customPrefixes);
var rPrefix = new RegExp('^(' + prefixes.join('|') + ')', 'ig');
return {
test: function (str) {
var $ = cheerio.load(str, {
recognizeSelfClosing: true
});
var foundPrefix = false;
$('*').each(function (i, el) {
// check tagName
rPrefix.lastIndex = 0;
foundPrefix = rPrefix.test(el.tagName);
// early exit
if (foundPrefix) {
return false;
}
// check attributes
var attrs = Object.keys($(el).attr()).filter(function (attr) {
rPrefix.lastIndex = 0;
return rPrefix.test(attr);
});
foundPrefix = attrs.length > 0;
// early exit
if (foundPrefix) {
return false;
}
});
return foundPrefix;
},
replace: function (str) {
var $ = cheerio.load(str, {
xmlMode: false,
decodeEntities: false,
normalizeWhitespace: false,
recognizeSelfClosing: true
});
$('*').each(function (i, el) {
var $el = $(el);
Object.keys($el.attr()).forEach(function (attr) {
rPrefix.lastIndex = 0;
if (!rPrefix.test(attr)) {
return;
}
$el.attr('data-' + attr, $el.attr(attr));
$el.removeAttr(attr);
});
// check tagName
rPrefix.lastIndex = 0;
if (rPrefix.test(el.tagName)) {
$el.replaceWith(function () {
return $('<data-' + el.tagName + '/>').attr($el.attr()).append($el.html());
});
}
});
return $.html();
}
};
};
var htmlify = require('./lib/angular-html5');
module.exports = exports = htmlify;

16

package.json
{
"name": "angular-html5",
"version": "2.2.1",
"version": "2.3.0",
"description": "Change your ng-attributes to data-ng-attributes for html5 validation",

@@ -35,12 +35,12 @@ "repository": "pgilad/angular-html5",

"devDependencies": {
"js-beautify": "^1.5.4",
"mocha": "*",
"should": "*"
"js-beautify": "^1.5.5",
"mocha": "^2.2.4",
"should": "^6.0.1"
},
"dependencies": {
"cheerio": "^0.18.0",
"commander": "^2.5.1",
"get-stdin": "^3.0.2",
"log-symbols": "^1.0.1"
"cheerio": "^0.19.0",
"commander": "^2.8.1",
"get-stdin": "^4.0.1",
"log-symbols": "^1.0.2"
}
}

@@ -97,7 +97,9 @@ # angular-html5

var str = fs.readFileSync('angular.html').toString();
var str = fs.readFileSync('angular.html', 'utf8');
var needsReplace = htmlify.test(str); //--> true if ng-attributes exist in file
// test if contents need replacing (testing is quick, replacing is slower)
var needsReplace = htmlify.test(str);
if (needsReplace) {
str = htmlify.replace(str); //--> returns the modified string with transformed attributes
// get the transformed html string with data- attributes
str = htmlify.replace(str);
}

@@ -108,8 +110,6 @@ ```

#### [Gulp](https://github.com/gulpjs/gulp) - See [gulp-angular-htmlify](https://github.com/pgilad/gulp-angular-htmlify)
#### [Gulp](https://github.com/gulpjs/gulp) - [gulp-angular-htmlify](https://github.com/pgilad/gulp-angular-htmlify)
#### [Grunt](http://gruntjs.com/) - See [grunt-angular-htmlify](https://github.com/pgilad/grunt-angular-htmlify)
#### [Grunt](http://gruntjs.com/) - [grunt-angular-htmlify](https://github.com/pgilad/grunt-angular-htmlify)
#### [Broccoli](https://github.com/broccolijs/broccoli) - ??
## API

@@ -116,0 +116,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc