Skip to content

Commit

Permalink
FIX: 清理元素样式时,只针对单位为 px 的 font-size 属性进行数值判断
Browse files Browse the repository at this point in the history
  • Loading branch information
biallo committed Jan 8, 2018
1 parent b9ce87c commit d10d0c9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simditor",
"version": "2.3.8",
"version": "2.3.9",
"homepage": "http://simditor.tower.im/",
"authors": [
"farthinker <farthinker@gmail.com>"
Expand Down
10 changes: 6 additions & 4 deletions lib/simditor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Simditor v2.3.8
* Simditor v2.3.9
* http://simditor.tower.im/
* 2017-12-11
* 2018-01-08
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
Expand Down Expand Up @@ -713,8 +713,10 @@ Formatter = (function(superClass) {
if (pair.length !== 2) {
continue;
}
if (pair[0] === 'font-size' && parseInt(pair[1], 10) < 12) {
continue;
if (pair[0] === 'font-size' && pair[1].indexOf('px') > 0) {
if (parseInt(pair[1], 10) < 12) {
continue;
}
}
if (ref1 = pair[0], indexOf.call(allowedStyles, ref1) >= 0) {
styles[$.trim(pair[0])] = $.trim(pair[1]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simditor",
"version": "2.3.8",
"version": "2.3.9",
"description": "A simple online editor",
"keywords": "editor simditor",
"repository": {
Expand Down
6 changes: 4 additions & 2 deletions site/assets/scripts/simditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,10 @@ Formatter = (function(superClass) {
if (pair.length !== 2) {
continue;
}
if (pair[0] === 'font-size' && parseInt(pair[1], 10) < 12) {
continue;
if (pair[0] === 'font-size' && pair[1].indexOf('px') > 0) {
if (parseInt(pair[1], 10) < 12) {
continue;
}
}
if (ref1 = pair[0], indexOf.call(allowedStyles, ref1) >= 0) {
styles[$.trim(pair[0])] = $.trim(pair[1]);
Expand Down
4 changes: 3 additions & 1 deletion src/formatter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ class Formatter extends SimpleModule
pair = style.split(':')

continue unless pair.length == 2
continue if pair[0] == 'font-size' and parseInt(pair[1], 10) < 12

if pair[0] == 'font-size' and pair[1].indexOf('px') > 0
continue if parseInt(pair[1], 10) < 12

styles[$.trim(pair[0])] = $.trim(pair[1]) if pair[0] in allowedStyles

Expand Down
4 changes: 2 additions & 2 deletions styles/simditor.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Simditor v2.3.8
* Simditor v2.3.9
* http://simditor.tower.im/
* 2017-12-11
* 2018-01-08
*/
@font-face {
font-family: 'Simditor';
Expand Down

0 comments on commit d10d0c9

Please sign in to comment.