@mapbox/hast-util-table-cell-style
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -5,3 +5,3 @@ { | ||
"node": true, | ||
"es6": true, | ||
"es6": false, | ||
"jest": true | ||
@@ -11,5 +11,4 @@ }, | ||
"rules": { | ||
"node/no-unsupported-features": ["error", {"version": 6}], | ||
"node/no-missing-require": ["error"] | ||
} | ||
} |
# Changelog | ||
## 0.1.3 | ||
- Use ES5 for browser compatibility. | ||
## 0.1.2 | ||
@@ -4,0 +8,0 @@ |
29
index.js
'use strict'; | ||
const visit = require('unist-util-visit'); | ||
var visit = require('unist-util-visit'); | ||
const hastCssPropertyMap = { | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
var hastCssPropertyMap = { | ||
align: 'text-align', | ||
@@ -21,22 +22,28 @@ valign: 'vertical-align', | ||
} | ||
Object.keys(hastCssPropertyMap).map(hastName => { | ||
if (node.properties[hastName] === undefined) { | ||
return; | ||
var hastName; | ||
var cssName; | ||
for (hastName in hastCssPropertyMap) { | ||
if ( | ||
!hasOwnProperty.call(hastCssPropertyMap, hastName) || | ||
node.properties[hastName] === undefined | ||
) { | ||
continue; | ||
} | ||
const cssName = hastCssPropertyMap[hastName]; | ||
cssName = hastCssPropertyMap[hastName]; | ||
appendStyle(node, cssName, node.properties[hastName]); | ||
delete node.properties[hastName]; | ||
}); | ||
} | ||
} | ||
function appendStyle(node, property, value) { | ||
let prevStyle = (node.properties.style || '').trim(); | ||
var prevStyle = (node.properties.style || '').trim(); | ||
if (prevStyle && !/;\s*/.test(prevStyle)) { | ||
prevStyle = `${prevStyle};`; | ||
prevStyle += ';'; | ||
} | ||
if (prevStyle) { | ||
prevStyle = `${prevStyle} `; | ||
prevStyle += ' '; | ||
} | ||
const nextStyle = `${prevStyle}${property}: ${value};`; | ||
var nextStyle = prevStyle + property + ': ' + value + ';'; | ||
node.properties.style = nextStyle; | ||
} |
{ | ||
"name": "@mapbox/hast-util-table-cell-style", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Transform deprecated styling attributes on HAST table cells to inline styles", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -0,1 +1,2 @@ | ||
/* eslint-env es6 */ | ||
'use strict'; | ||
@@ -2,0 +3,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14024
213