Socket
Socket
Sign inDemoInstall

line-height

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

.jscsrc

2

CHANGELOG.md
# line-height changelog
0.2.1 - Added new linting and simplified tests
0.2.0 - Moved from testem and Testling to Karma and Travis CI

@@ -3,0 +5,0 @@

2

component.json
{
"name": "line-height",
"repo": "twolfson/line-height",
"version": "0.2.0",
"version": "0.2.1",
"description": "Calculate line-height of an HTML element (IE6 compatible)",

@@ -6,0 +6,0 @@ "dependencies": {

@@ -12,4 +12,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.lineHeight = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

// Grab the line-height via style
var lnHeightStr = computedStyle(node, 'line-height'),
lnHeight = parseFloat(lnHeightStr, 10);
var lnHeightStr = computedStyle(node, 'line-height');
var lnHeight = parseFloat(lnHeightStr, 10);

@@ -40,15 +40,15 @@ // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')

lnHeight /= 3;
// Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
} else if (lnHeightStr.indexOf('mm') !== -1) {
// Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
lnHeight *= 96;
lnHeight /= 25.4;
// Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
} else if (lnHeightStr.indexOf('cm') !== -1) {
// Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
lnHeight *= 96;
lnHeight /= 2.54;
// Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
} else if (lnHeightStr.indexOf('in') !== -1) {
// Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
lnHeight *= 96;
// Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
} else if (lnHeightStr.indexOf('pc') !== -1) {
// Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
lnHeight *= 16;

@@ -63,4 +63,4 @@ }

// Create a temporary node
var nodeName = node.nodeName,
_node = document.createElement(nodeName);
var nodeName = node.nodeName;
var _node = document.createElement(nodeName);
_node.innerHTML = '&nbsp;';

@@ -90,2 +90,3 @@

module.exports = lineHeight;
},{"computed-style":2}],2:[function(require,module,exports){

@@ -92,0 +93,0 @@ // This code has been refactored for 140 bytes

@@ -11,4 +11,4 @@ // Load in dependencies

// Grab the line-height via style
var lnHeightStr = computedStyle(node, 'line-height'),
lnHeight = parseFloat(lnHeightStr, 10);
var lnHeightStr = computedStyle(node, 'line-height');
var lnHeight = parseFloat(lnHeightStr, 10);

@@ -39,15 +39,15 @@ // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')

lnHeight /= 3;
// Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
} else if (lnHeightStr.indexOf('mm') !== -1) {
// Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
lnHeight *= 96;
lnHeight /= 25.4;
// Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
} else if (lnHeightStr.indexOf('cm') !== -1) {
// Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
lnHeight *= 96;
lnHeight /= 2.54;
// Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
} else if (lnHeightStr.indexOf('in') !== -1) {
// Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
lnHeight *= 96;
// Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
} else if (lnHeightStr.indexOf('pc') !== -1) {
// Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
lnHeight *= 16;

@@ -62,4 +62,4 @@ }

// Create a temporary node
var nodeName = node.nodeName,
_node = document.createElement(nodeName);
var nodeName = node.nodeName;
var _node = document.createElement(nodeName);
_node.innerHTML = '&nbsp;';

@@ -88,2 +88,2 @@

// Export lineHeight
module.exports = lineHeight;
module.exports = lineHeight;
{
"name": "line-height",
"description": "Calculate line-height of an HTML element (IE6 compatible)",
"version": "0.2.0",
"version": "0.2.1",
"homepage": "https://github.com/twolfson/line-height",

@@ -18,8 +18,3 @@ "author": {

},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/twolfson/line-height/blob/master/LICENSE-MIT"
}
],
"license": "MIT",
"main": "lib/line-height",

@@ -31,3 +26,4 @@ "engines": {

"build": "browserify lib/line-height.js --standalone line-height --outfile dist/line-height.js",
"test": "npm run build && npm run test-karma-single",
"lint": "twolfson-style lint lib/ test/",
"test": "npm run build && npm run test-karma-single && npm run lint",
"_test-karma-comment": "`xvfb-maybe` checks for DISPLAY environment variable but we hate non-headless browsers so we always shut it off",

@@ -49,3 +45,2 @@ "test-karma-continuous": "DISPLAY=\"\" xvfb-maybe karma start --no-single-run",

"foundry-release-npm": "~2.0.2",
"grunt": "~0.3.17",
"karma": "~1.4.1",

@@ -56,4 +51,5 @@ "karma-browserify": "~5.1.1",

"karma-phantomjs-launcher": "~1.0.2",
"mocha": "~1.11.0",
"mocha": "~3.2.0",
"proclaim": "~3.4.4",
"twolfson-style": "~1.6.1",
"xvfb-maybe": "~0.1.3"

@@ -60,0 +56,0 @@ },

@@ -126,3 +126,3 @@ # line-height [![Build status](https://travis-ci.org/twolfson/line-height.svg?branch=master)](https://travis-ci.org/twolfson/line-height)

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via [grunt](https://github.com/gruntjs/grunt) and test via `npm test`.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via `npm run lint` and test via `npm test`.

@@ -129,0 +129,0 @@ ## License

// Load in test dependencies
var lineHeight = require('../lib/line-height.js'),
assert = require('proclaim'),
domify = require('domify'),
cssControls = require('css-controls');
var lineHeight = require('../lib/line-height.js');
var assert = require('proclaim');
var domify = require('domify');
var cssControls = require('css-controls');
// Create common fixture actions
function fixtureNode() {
before(function () {
var node = domify(this.html);
document.body.appendChild(node);
this.node = node;
});
after(function () {
document.body.removeChild(this.node);
});
}
var styleSheet = cssControls.createStyleSheet();
var testUtils = {
getLineHeight: function (html) {
before(function () {
// Save our line height
this.node = domify(html);
document.body.appendChild(this.node);
this.lineHeight = lineHeight(this.node);
function processNode() {
before(function () {
this.lineHeight = lineHeight(this.node);
});
// Sanity check line height is a number
assert.strictEqual(typeof this.lineHeight, 'number');
assert.notEqual(isNaN(this.lineHeight), true);
});
after(function cleanup () {
document.body.removeChild(this.node);
delete this.node;
delete this.lineHeight;
});
},
styleBody: function (css) {
before(function styleBodyFn () {
document.body.style.cssText = css;
});
after(function cleanup () {
document.body.style.cssText = '';
});
},
addGlobalCss: function (selector, rule) {
var index;
before(function addGlobalCssFn () {
index = cssControls.addRule(styleSheet, selector, rule);
});
after(function cleanup () {
cssControls.removeRule(styleSheet, index);
});
}
};
it('has a line-height which is a number', function () {
assert.strictEqual(typeof this.lineHeight, 'number');
assert.notEqual(isNaN(this.lineHeight), true);
});
}
function styleBody(css) {
before(function () {
document.body.style.cssText = css;
});
after(function () {
document.body.style.cssText = '';
});
}
var styleSheet = cssControls.createStyleSheet();
function globalStyle(selector, rule) {
var index;
before(function () {
index = cssControls.addRule(styleSheet, selector, rule);
});
after(function () {
cssControls.removeRule(styleSheet, index);
});
}
// Basic tests
var _defaultLnHeight;
describe('An unstyled div', function () {
before(function () {
this.html = '<div>abc</div>';
describe('An unstyled div processed by line-height', function () {
testUtils.getLineHeight('<div>abc</div>');
// Save the line height for other tests
before(function saveDefaultLineHeight () {
_defaultLnHeight = this.lineHeight;
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
before(function () {
// Save the line height for other tests
_defaultLnHeight = this.lineHeight;
});
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
});
describe('A line-height styled div', function () {
before(function () {
this.html = '<div style="line-height: 50px;">abc</div>';
});
fixtureNode();
describe('A line-height styled div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 50px;">abc</div>');
describe('processed by line-height', function () {
processNode();
it('has the styled line-height\'s height', function () {
assert.strictEqual(this.lineHeight, 50);
});
it('has the styled line-height\'s height', function () {
assert.strictEqual(this.lineHeight, 50);
});

@@ -89,20 +70,13 @@ });

// DEV: Tests and disproves that an element has a constant ratio for its font-size
describe('A font-size styled div', function () {
before(function () {
this.html = '<div style="font-size: 50px;">abc</div>';
describe('A font-size styled div processed by line-height', function () {
testUtils.getLineHeight('<div style="font-size: 50px;">abc</div>');
it('has the styled line-height\'s height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has the styled line-height\'s height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
it('has a line-height greater than the its font-size', function () {
var lnHeight = this.lineHeight;
assert.ok(lnHeight > 50, 'Expected: > 50, Actual: ' + lnHeight);
});
it('has a line-height greater than the its font-size', function () {
var lnHeight = this.lineHeight;
assert.greaterThan(lnHeight, 50);
});

@@ -112,43 +86,29 @@ });

// Intermediate tests
describe('A percentage line-height div', function () {
before(function () {
this.html = '<div style="line-height: 150%;">abc</div>';
describe('A percentage line-height div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 150%;">abc</div>');
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
it('has a line-height greater than the default', function () {
// DEV: In IE6, 150% !== default * 1.5; 24 !== 28.5 (19 * 1.5)
var lnHeight = this.lineHeight;
assert.ok(lnHeight > _defaultLnHeight, 'Expected: > ' + _defaultLnHeight + ' (default), Actual: ' + lnHeight);
});
it('has a line-height greater than the default', function () {
// DEV: In IE6, 150% !== default * 1.5; 24 !== 28.5 (19 * 1.5)
var lnHeight = this.lineHeight;
assert.greaterThan(lnHeight, _defaultLnHeight);
});
});
describe('A relative line-height div', function () {
before(function () {
this.html = '<div style="line-height: 3em;">abc</div>';
describe('A relative line-height div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 3em;">abc</div>');
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
it('has a line-height greater than the default', function () {
// DEV: In IE6, 1.3em !== default * 1.3; 22 !== 24.7 (19 * 1.3)
var lnHeight = this.lineHeight;
assert.ok(lnHeight > _defaultLnHeight, 'Expected: > ' + _defaultLnHeight + ' (default), Actual: ' + lnHeight);
});
it('has a line-height greater than the default', function () {
// DEV: In IE6, 1.3em !== default * 1.3; 22 !== 24.7 (19 * 1.3)
var lnHeight = this.lineHeight;
assert.greaterThan(lnHeight, _defaultLnHeight);
});

@@ -158,37 +118,22 @@ });

// DEV: This is redundant but the test name is practical
describe('An absolute line-height div', function () {
before(function () {
this.html = '<div style="line-height: 50px;">abc</div>';
});
fixtureNode();
describe('An absolute line-height div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 50px;">abc</div>');
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to 50px', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, 50);
});
it('has a line-height equal to 50px', function () {
assert.strictEqual(this.lineHeight, 50);
});
});
describe('A numeric line-height div', function () {
before(function () {
this.html = '<div style="line-height: 2.3;">abc</div>';
describe('A numeric line-height div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 2.3;">abc</div>');
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
it('has a line-height greater than the default', function () {
// DEV: In IE6, 2.3 !== default * 2.3; 37 !== 43.6999... (19 * 2.3)
var lnHeight = this.lineHeight;
assert.ok(lnHeight > _defaultLnHeight, 'Expected: > ' + _defaultLnHeight + ' (default), Actual: ' + lnHeight);
});
it('has a line-height greater than the default', function () {
// DEV: In IE6, 2.3 !== default * 2.3; 37 !== 43.6999... (19 * 2.3)
var lnHeight = this.lineHeight;
assert.greaterThan(lnHeight, _defaultLnHeight);
});

@@ -198,15 +143,8 @@ });

// Verify ancestor -> descendant works on global styling to node level
describe('An inherit line-height div', function () {
before(function () {
this.html = '<div style="line-height: inherit;">abc</div>';
});
styleBody('line-height: 40px;');
fixtureNode();
describe('An inherit line-height div processed by line-height', function () {
testUtils.styleBody('line-height: 40px;');
testUtils.getLineHeight('<div style="line-height: inherit;">abc</div>');
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to the inherited amount', function () {
assert.strictEqual(this.lineHeight, 40);
});
it('has a line-height equal to the inherited amount', function () {
assert.strictEqual(this.lineHeight, 40);
});

@@ -216,17 +154,8 @@ });

// Verify ancestor -> descendant works on node to node level
describe('A child in a styled div', function () {
before(function () {
this.html = '<div style="line-height: 50px;"><div id="child">abc</div></div>';
});
fixtureNode();
describe('A child in a styled div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 50px;"><div id="child">abc</div></div>');
describe('processed by line-height', function () {
before(function () {
var childNode = document.getElementById('child');
this.lineHeight = lineHeight(childNode);
});
it('has a line-height equal to the parent\'s line-height', function () {
assert.strictEqual(this.lineHeight, 50);
});
it('has a line-height equal to the parent\'s line-height', function () {
var childNode = document.getElementById('child');
assert.strictEqual(lineHeight(childNode), 50);
});

@@ -237,21 +166,14 @@ });

// Verify more global styling inheritance
describe('A globally styled body and an unstyled div', function () {
before(function () {
this.html = '<div>abc</div>';
describe('A globally styled body and an unstyled div processed by line-height', function () {
testUtils.styleBody('font-size: 40px;');
testUtils.getLineHeight('<div>abc</div>');
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
styleBody('font-size: 40px;');
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
it('has a line-height greater than the body\'s font-size', function () {
var lnHeight = this.lineHeight;
assert.ok(lnHeight > 40, 'Expected: > 40, Actual: ' + lnHeight);
});
it('has a line-height greater than the body\'s font-size', function () {
var lnHeight = this.lineHeight;
assert.greaterThan(lnHeight, 40);
});

@@ -262,20 +184,13 @@ });

// Testing a pt unit type explicitly
describe('A pt line-height div', function () {
before(function () {
this.html = '<div style="line-height: 27pt;">abc</div>';
describe('A pt line-height div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 27pt;">abc</div>');
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
// DEV: This verifies our conversion is correct
it('has a line-height of 36px', function () {
assert.strictEqual(this.lineHeight, 36); // 27 * 4/3
});
// DEV: This verifies our conversion is correct
it('has a line-height of 36px', function () {
assert.strictEqual(this.lineHeight, 36); // 27 * 4/3
});

@@ -285,20 +200,13 @@ });

// Testing a mm unit type explicitly (IE6)
describe('A mm line-height div', function () {
before(function () {
this.html = '<div style="line-height: 50.8mm;">abc</div>';
describe('A mm line-height div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 50.8mm;">abc</div>');
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
// DEV: This verifies our conversion is correct
it('has a line-height of 192px', function () {
assert.strictEqual(this.lineHeight, 192); // 50.8 * 96/25.4
});
// DEV: This verifies our conversion is correct
it('has a line-height of 192px', function () {
assert.strictEqual(this.lineHeight, 192); // 50.8 * 96/25.4
});

@@ -308,20 +216,13 @@ });

// Testing a cm unit type explicitly (IE6)
describe('A cm line-height div', function () {
before(function () {
this.html = '<div style="line-height: 2.54cm;">abc</div>';
describe('A cm line-height div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 2.54cm;">abc</div>');
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
// DEV: This verifies our conversion is correct
it('has a line-height of 96px', function () {
assert.strictEqual(this.lineHeight, 96); // 2.54 * 96/2.54
});
// DEV: This verifies our conversion is correct
it('has a line-height of 96px', function () {
assert.strictEqual(this.lineHeight, 96); // 2.54 * 96/2.54
});

@@ -331,20 +232,13 @@ });

// Testing a in unit type explicitly (IE6)
describe('A in line-height div', function () {
before(function () {
this.html = '<div style="line-height: 2in;">abc</div>';
describe('A in line-height div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 2in;">abc</div>');
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
// DEV: This verifies our conversion is correct
it('has a line-height of 192px', function () {
assert.strictEqual(this.lineHeight, 192); // 2 * 96
});
// DEV: This verifies our conversion is correct
it('has a line-height of 192px', function () {
assert.strictEqual(this.lineHeight, 192); // 2 * 96
});

@@ -354,20 +248,13 @@ });

// Testing a pc unit type explicitly (IE6)
describe('A pc line-height div', function () {
before(function () {
this.html = '<div style="line-height: 2pc;">abc</div>';
describe('A pc line-height div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 2pc;">abc</div>');
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
// DEV: This verifies our conversion is correct
it('has a line-height of 32px', function () {
assert.strictEqual(this.lineHeight, 32); // 2pc * 12pt/1pc * 4px/3pt
});
// DEV: This verifies our conversion is correct
it('has a line-height of 32px', function () {
assert.strictEqual(this.lineHeight, 32); // 2pc * 12pt/1pc * 4px/3pt
});

@@ -378,46 +265,30 @@ });

// DEV: Units taken from https://developer.mozilla.org/en-US/docs/Web/CSS/length
var cssLengths = ['em', 'ex', 'ch', 'rem', 'vh', 'vw', 'vmin', 'vmax', 'px', 'mm', 'cm', 'in', 'pt', 'pc', 'mozmm'],
i = cssLengths.length;
function testCssLength(cssLength) {
describe('A ' + cssLength + ' line-height div', function () {
before(function () {
this.html = '<div style="line-height: 20' + cssLength + ';">abc</div>';
});
fixtureNode();
describe('A ' + cssLength + ' line-height div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 20' + cssLength + ';">abc</div>');
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.greaterThanOrEqual(this.lineHeight, height - 1);
assert.lessThanOrEqual(this.lineHeight, height + 1);
});
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.greaterThanOrEqual(this.lineHeight, height - 1);
assert.lessThanOrEqual(this.lineHeight, height + 1);
});
});
}
while (i--) {
var cssLengths = ['em', 'ex', 'ch', 'rem', 'vh', 'vw', 'vmin', 'vmax', 'px', 'mm', 'cm', 'in', 'pt', 'pc', 'mozmm'];
for (var i = 0; i < cssLengths; i += 1) {
testCssLength(cssLengths[i]);
}
// Verify there is no bleeding between
describe('An em line-height with a pt font div processed by line-height', function () {
testUtils.getLineHeight('<div style="line-height: 2.5em; font-size: 33pt;">abc</div>');
// Verify there is no bleeding between
describe('An em line-height with a pt font div', function () {
before(function () {
this.html = '<div style="line-height: 2.5em; font-size: 33pt;">abc</div>';
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
it('has a line-height greater than the default', function () {
var lnHeight = this.lineHeight;
assert.ok(lnHeight > _defaultLnHeight, 'Expected: > ' + _defaultLnHeight + ' (default), Actual: ' + lnHeight);
});
it('has a line-height greater than the default', function () {
var lnHeight = this.lineHeight;
assert.greaterThan(lnHeight, _defaultLnHeight);
});

@@ -427,22 +298,15 @@ });

// Verify we return a line-height specific for a the tag type (e.g. h2 over div)
describe('A div-specific font-size style and an h2', function () {
before(function () {
this.html = '<h2>abc</h2>';
describe('A div-specific font-size style and an h2 processed by line-height', function () {
testUtils.addGlobalCss('div', 'font-size: 60px;');
testUtils.getLineHeight('<h2>abc</h2>');
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
globalStyle('div', 'font-size: 60px;');
fixtureNode();
describe('processed by line-height', function () {
processNode();
it('has a line-height equal to its height', function () {
var height = this.node.offsetHeight;
assert.strictEqual(this.lineHeight, height);
});
it('has a line-height under the div font-size', function () {
var lnHeight = this.lineHeight;
assert.ok(lnHeight < 60, 'Expected: < 60, Actual: ' + lnHeight);
});
it('has a line-height under the div font-size', function () {
var lnHeight = this.lineHeight;
assert.lessThan(lnHeight, 50);
});
});
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