-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored html-tools and htmljs to move ES6 version #385
base: release-3.0
Are you sure you want to change the base?
Changes from 19 commits
d9c3ada
48b6c77
895c109
e65274b
24ed805
a8cee70
836c76e
366d397
e18db10
b6d8d77
e2bed38
8bde88f
8e47093
7ebe904
b077fc7
cc378df
3bd7704
bc17f49
b388410
b6a0019
51c5592
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,55 @@ | ||
/* eslint-env meteor */ | ||
import { HTMLTools } from 'meteor/html-tools'; | ||
|
||
var Scanner = HTMLTools.Scanner; | ||
var getCharacterReference = HTMLTools.Parse.getCharacterReference; | ||
const { Scanner } = HTMLTools; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think the old way was more straightforward to read - |
||
const { getCharacterReference } = HTMLTools.Parse; | ||
|
||
Tinytest.add("html-tools - entities", function (test) { | ||
var succeed = function (input, match, codepoints) { | ||
if (typeof input === 'string') | ||
input = {input: input}; | ||
Tinytest.add('html-tools - entities', function (test) { | ||
const succeed = function (input, match, codepoints) { | ||
if (typeof input === 'string') input = { input }; | ||
|
||
// match arg is optional; codepoints is never a string | ||
if (typeof match !== 'string') { | ||
codepoints = match; | ||
match = input.input; | ||
} | ||
|
||
var scanner = new Scanner(input.input); | ||
var result = getCharacterReference(scanner, input.inAttribute, input.allowedChar); | ||
const scanner = new Scanner(input.input); | ||
const result = getCharacterReference(scanner, input.inAttribute, input.allowedChar); | ||
test.isTrue(result); | ||
test.equal(scanner.pos, match.length); | ||
test.equal(result, { | ||
t: 'CharRef', | ||
v: match, | ||
cp: codepoints.map( | ||
function (x) { return (typeof x === 'string' ? | ||
x.charCodeAt(0) : x); }) | ||
function (x) { | ||
return (typeof x === 'string' ? | ||
x.charCodeAt(0) : x); | ||
}), | ||
}); | ||
}; | ||
|
||
var ignore = function (input) { | ||
if (typeof input === 'string') | ||
input = {input: input}; | ||
const ignore = function (input) { | ||
if (typeof input === 'string') input = { input }; | ||
|
||
var scanner = new Scanner(input.input); | ||
var result = getCharacterReference(scanner, input.inAttribute, input.allowedChar); | ||
const scanner = new Scanner(input.input); | ||
const result = getCharacterReference(scanner, input.inAttribute, input.allowedChar); | ||
test.isFalse(result); | ||
test.equal(scanner.pos, 0); | ||
}; | ||
|
||
var fatal = function (input, messageContains) { | ||
if (typeof input === 'string') | ||
input = {input: input}; | ||
const fatal = function (input, messageContains) { | ||
if (typeof input === 'string') input = { input }; | ||
|
||
var scanner = new Scanner(input.input); | ||
var error; | ||
const scanner = new Scanner(input.input); | ||
let error; | ||
try { | ||
getCharacterReference(scanner, input.inAttribute, input.allowedChar); | ||
} catch (e) { | ||
error = e; | ||
} | ||
test.isTrue(error); | ||
if (error) | ||
test.isTrue(messageContains && error.message.indexOf(messageContains) >= 0, error.message); | ||
if (error) test.isTrue(messageContains && error.message.indexOf(messageContains) >= 0, error.message); | ||
}; | ||
|
||
ignore('a'); | ||
|
@@ -61,15 +60,15 @@ Tinytest.add("html-tools - entities", function (test) { | |
fatal('&#', 'Invalid numerical character reference starting with &#'); | ||
ignore('&a'); | ||
fatal('&a;', 'Invalid character reference: &a;'); | ||
ignore({input: '&"', allowedChar: '"'}); | ||
ignore({ input: '&"', allowedChar: '"' }); | ||
ignore('&"'); | ||
|
||
succeed('>', ['>']); | ||
fatal('>', 'Character reference requires semicolon'); | ||
ignore('&aaa'); | ||
fatal('>a', 'Character reference requires semicolon'); | ||
ignore({input: '>a', inAttribute: true}); | ||
fatal({input: '>=', inAttribute: true}, 'Character reference requires semicolon: >'); | ||
ignore({ input: '>a', inAttribute: true }); | ||
fatal({ input: '>=', inAttribute: true }, 'Character reference requires semicolon: >'); | ||
|
||
succeed('>;', '>', ['>']); | ||
|
||
|
@@ -112,5 +111,4 @@ Tinytest.add("html-tools - entities", function (test) { | |
fatal('', 'Illegal codepoint in numerical character reference'); | ||
fatal('', 'Illegal codepoint in numerical character reference'); | ||
succeed('􏿽', [0x10fffd]); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
/* eslint-env meteor */ | ||
Package.describe({ | ||
name: 'html-tools', | ||
summary: "Standards-compliant HTML tools", | ||
version: '1.1.3', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @StorytellerCZ @denihs should PRs to 3.0 include version bumps? I'd rather keep them and at release bump them to whatever is suitable but that's not my call. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ping @Grubba27 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I think PRs probably shouldn't include individual version bumps, it feels like this way lie merge conflicts & conflicting version number schemes for sure :D |
||
git: 'https://github.com/meteor/blaze.git' | ||
summary: 'Standards-compliant HTML tools', | ||
version: '1.2.0', | ||
git: 'https://github.com/meteor/blaze.git', | ||
}); | ||
|
||
Package.onUse(function (api) { | ||
|
@@ -25,6 +26,6 @@ Package.onTest(function (api) { | |
api.addFiles([ | ||
'charref_tests.js', | ||
'tokenize_tests.js', | ||
'parse_tests.js' | ||
'parse_tests.js', | ||
]); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question @jankapunkt @guncebektas : Does this have to be included in different files? Isn't there a default .eslintrc or something for blaze which should contain this?