Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html-attribute-sorter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-attribute-sorter - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

15

CHANGELOG.md
# Changelog
### [0.2.1](https://www.github.com/shufo/html-attribute-sorter/compare/v0.2.0...v0.2.1) (2022-08-06)
### Fixes
* 🐛 regex does not match specific tag ([6d94431](https://www.github.com/shufo/html-attribute-sorter/commit/6d944314fb2c68950527ed8a7992c15e98b0dfc5))
### Miscellaneous
* **deps:** update actions/cache action to v3 ([094a395](https://www.github.com/shufo/html-attribute-sorter/commit/094a395bcdf5137efed4971449aac3973c688fb0))
* **deps:** update actions/checkout action to v3 ([b109c93](https://www.github.com/shufo/html-attribute-sorter/commit/b109c93259e443f8bb916418b3488f5096d73c86))
* **deps:** update actions/setup-node action to v3 ([0ca780e](https://www.github.com/shufo/html-attribute-sorter/commit/0ca780ecd9c04d7f78673d95f01d6d49c08ae275))
* **deps:** update codecov/codecov-action action to v3 ([38b87de](https://www.github.com/shufo/html-attribute-sorter/commit/38b87deb8630302fedbeb5e384cdf22b3a97e730))
## [0.2.0](https://www.github.com/shufo/html-attribute-sorter/compare/v0.1.0...v0.2.0) (2022-08-05)

@@ -4,0 +19,0 @@

2

dist/main.js

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

"use strict";var l=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var x=(r,t)=>{for(var e in t)l(r,e,{get:t[e],enumerable:!0})},w=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of h(t))!y.call(r,s)&&s!==e&&l(r,s,{get:()=>t[s],enumerable:!(o=_(t,s))||o.enumerable});return r};var A=r=>w(l({},"__esModule",{value:!0}),r);var T={};x(T,{sortAttributes:()=>b});module.exports=A(T);var a=class{constructor(t){this.strategy=t}setStrategy(t){this.strategy=t}sort(t){return this.strategy.sort(t)}};var g=class{sort(t){return t.sort()}};var c=class{constructor(){this.orderedAttrsRegex=["class","id","name","data-.+","ng-.+","src","for","type","href","value","values","title","alt","role","aria-.+","tabindex","style"]}sort(t){let e=[];this.orderedAttrsRegex.forEach(s=>{t.forEach(n=>{new RegExp(`^${s}`).test(n)&&e.push(n)})});let o=t.filter(s=>e.indexOf(s)===-1).sort();return e.concat(o)}};var d=class{constructor(){this.orderedAttrsRegex=["class","id","data-.+"]}sort(t){let e=[];this.orderedAttrsRegex.forEach(s=>{t.forEach(n=>{new RegExp(`^${s}`).test(n)&&e.push(n)})});let o=t.filter(s=>e.indexOf(s)===-1).sort();return e.concat(o)}};var m=[],f=[];function b(r,t={order:"code_guide"}){let e=r.replace(/<[-:.\w\d]+\s+([-:.\w\d]+)=("[^"]*"|'[^']*'|[^"'])*?>/g,(o,s)=>E(s,o));return I(e,t)}function E(r,t){let e=m.push(t)-1;return R(r,e.toString())}function O(r,t){let e=f.push(t)-1;return v(r,e.toString())}function R(r,t){return"___sort_tags_#___".replace("#",t)}function v(r,t){return`${r}_attrs_#___`.replace("#",t)}function I(r,t){return r.replace(/___sort_tags_(\d+)___/g,(e,o)=>{let n=m[o].replace(/([-:.\w\d]+)=("[^"]*"|'[^']*'|[^"'])/g,(i,p)=>O(p,i));return $(n,t).replace(/[-:.\w\d]+_attrs_(\d+)___/g,(i,p)=>f[p])})}function $(r,t){let e=P(t.order),o=new a(e);return r.replace(/(?<=<[-:.\w\d]+\s)[^>]*?(?=\/?>)/g,s=>{let u=s.split(/\s/).filter(i=>i.length>0);return o.sort(u).join(" ")})}function P(r){switch(r){case"alphabetical":return new g;case"code_guide":return new c;case"idiomatic":return new d}}0&&(module.exports={sortAttributes});
"use strict";var l=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var x=(r,t)=>{for(var e in t)l(r,e,{get:t[e],enumerable:!0})},A=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of h(t))!y.call(r,s)&&s!==e&&l(r,s,{get:()=>t[s],enumerable:!(o=_(t,s))||o.enumerable});return r};var w=r=>A(l({},"__esModule",{value:!0}),r);var T={};x(T,{sortAttributes:()=>b});module.exports=w(T);var a=class{constructor(t){this.strategy=t}setStrategy(t){this.strategy=t}sort(t){return this.strategy.sort(t)}};var g=class{sort(t){return t.sort()}};var c=class{constructor(){this.orderedAttrsRegex=["class","id","name","data-.+","ng-.+","src","for","type","href","value","values","title","alt","role","aria-.+","tabindex","style"]}sort(t){let e=[];this.orderedAttrsRegex.forEach(s=>{t.forEach(n=>{new RegExp(`^${s}`).test(n)&&e.push(n)})});let o=t.filter(s=>e.indexOf(s)===-1).sort();return e.concat(o)}};var p=class{constructor(){this.orderedAttrsRegex=["class","id","data-.+"]}sort(t){let e=[];this.orderedAttrsRegex.forEach(s=>{t.forEach(n=>{new RegExp(`^${s}`).test(n)&&e.push(n)})});let o=t.filter(s=>e.indexOf(s)===-1).sort();return e.concat(o)}};var f=[],m=[];function b(r,t={order:"code_guide"}){let e=r.replace(/<(?!\/)(?:"[^"]*"|'[^']*'|[^"'])*?>/g,o=>E(o));return I(e,t)}function E(r){let t=f.push(r)-1;return R(t.toString())}function O(r,t){let e=m.push(t)-1;return v(r,e.toString())}function R(r){return"___sort_tags_#___".replace("#",r)}function v(r,t){return`${r}_attrs_#___`.replace("#",t)}function I(r,t){return r.replace(/___sort_tags_(\d+)___/g,(e,o)=>{let n=f[o].replace(/([-:.\w\d]+)=("[^"]*"|'[^']*'|[^"'])/g,(i,d)=>O(d,i));return $(n,t).replace(/[-:.\w\d]+_attrs_(\d+)___/g,(i,d)=>m[d])})}function $(r,t){let e=P(t.order),o=new a(e);return r.replace(/(?<=<[-:.\w\d]+\s)[^>]*?(?=\/?>)/g,s=>{let u=s.split(/\s/).filter(i=>i.length>0);return o.sort(u).join(" ")})}function P(r){switch(r){case"alphabetical":return new g;case"code_guide":return new c;case"idiomatic":return new p}}0&&(module.exports={sortAttributes});
//# sourceMappingURL=main.js.map
{
"name": "html-attribute-sorter",
"version": "0.2.0",
"version": "0.2.1",
"description": "An html attribute sorter",

@@ -5,0 +5,0 @@ "main": "dist/main.js",

@@ -15,5 +15,5 @@ import { ISortOption, Strategy } from "./options";

const replaced = html.replace(
/<[-:.\w\d]+\s+([-:.\w\d]+)=("[^"]*"|'[^']*'|[^"'])*?>/g,
(match: string, p1: string) => {
return storeTags(p1, match);
/<(?!\/)(?:"[^"]*"|'[^']*'|[^"'])*?>/g,
(match: string) => {
return storeTags(match);
}

@@ -25,5 +25,5 @@ );

function storeTags(name: string, value: string) {
function storeTags(value: string) {
const index = maps.push(value) - 1;
return getTagPlaceholder(name, index.toString());
return getTagPlaceholder(index.toString());
}

@@ -36,3 +36,3 @@

function getTagPlaceholder(name, index: string) {
function getTagPlaceholder(index: string) {
return `___sort_tags_#___`.replace("#", index);

@@ -39,0 +39,0 @@ }

Sorry, the diff of this file is not supported yet

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