style: single quotes (#526)

pull/527/head
Shahar Dawn Or 5 years ago committed by GitHub
parent 431f95018e
commit ad3745bfe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,7 +13,6 @@ module.exports = {
'@typescript-eslint/member-delimiter-style': 'off', '@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off', '@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off', '@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/quotes': 'off',
'@typescript-eslint/restrict-plus-operands': 'off', '@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off', '@typescript-eslint/strict-boolean-expressions': 'off',
'comma-dangle': 'off', 'comma-dangle': 'off',
@ -31,7 +30,6 @@ module.exports = {
'prefer-const': 'off', 'prefer-const': 'off',
'quote-props': 'off', 'quote-props': 'off',
eqeqeq: 'off', eqeqeq: 'off',
quotes: 'off',
semi: 'off' semi: 'off'
} }
} }

@ -14,23 +14,23 @@ var data = {
function gRotation () { function gRotation () {
// console.log("gRotation: %s", data.degRotation); // console.log("gRotation: %s", data.degRotation);
return "rotate(" + data.degRotation + "deg)"; return 'rotate(' + data.degRotation + 'deg)';
} }
function triangleClick (id) { function triangleClick (id) {
console.log("triangleClick: %s", id); console.log('triangleClick: %s', id);
render(); render();
} }
function handleRotate (degs) { function handleRotate (degs) {
data.degRotation += degs; data.degRotation += degs;
console.log("handleRotate: %s, %s", degs, data.degRotation); console.log('handleRotate: %s, %s', degs, data.degRotation);
render(); render();
} }
function handleReset (degs) { function handleReset (degs) {
data.degRotation = degs; data.degRotation = degs;
console.log("handleReset: %s", degs); console.log('handleReset: %s', degs);
render(); render();
} }
@ -39,36 +39,36 @@ function render () {
} }
const hTriangle = (id, degRotation) => const hTriangle = (id, degRotation) =>
h("polygon#" + id, { h('polygon#' + id, {
attrs: { attrs: {
points: "-50,-88 0,-175 50,-88", points: '-50,-88 0,-175 50,-88',
transform: "rotate(" + degRotation + ")", transform: 'rotate(' + degRotation + ')',
"stroke-width": 3 'stroke-width': 3
}, },
on: { click: [triangleClick, id] } on: { click: [triangleClick, id] }
}); });
const view = (data) => const view = (data) =>
h("div.view", [ h('div.view', [
h("h1", "Snabbdom SVG Carousel"), h('h1', 'Snabbdom SVG Carousel'),
h("svg", { attrs: { width: 380, height: 380, viewBox: [-190, -190, 380, 380] } }, [ h('svg', { attrs: { width: 380, height: 380, viewBox: [-190, -190, 380, 380] } }, [
h("g#carousel", h('g#carousel',
{ style: { "-webkit-transform": gRotation(), transform: gRotation() } }, [ { style: { '-webkit-transform': gRotation(), transform: gRotation() } }, [
hTriangle("yellow", 0), hTriangle('yellow', 0),
hTriangle("green", 60), hTriangle('green', 60),
hTriangle("magenta", 120), hTriangle('magenta', 120),
hTriangle("red", 180), hTriangle('red', 180),
hTriangle("cyan", 240), hTriangle('cyan', 240),
hTriangle("blue", 300) hTriangle('blue', 300)
]) ])
]), ]),
h("button", { on: { click: [handleRotate, 60] } }, "Rotate Clockwise"), h('button', { on: { click: [handleRotate, 60] } }, 'Rotate Clockwise'),
h("button", { on: { click: [handleRotate, -60] } }, "Rotate Anticlockwise"), h('button', { on: { click: [handleRotate, -60] } }, 'Rotate Anticlockwise'),
h("button", { on: { click: [handleReset, 0] } }, "Reset") h('button', { on: { click: [handleReset, 0] } }, 'Reset')
]); ]);
window.addEventListener("DOMContentLoaded", () => { window.addEventListener('DOMContentLoaded', () => {
var container = document.getElementById("container"); var container = document.getElementById('container');
vnode = patch(container, view(data)); vnode = patch(container, view(data));
render(); render();
}); });

@ -32,7 +32,7 @@ function updateAttrs (oldVnode: VNode, vnode: VNode): void {
const old = oldAttrs[key]; const old = oldAttrs[key];
if (old !== cur) { if (old !== cur) {
if (cur === true) { if (cur === true) {
elm.setAttribute(key, ""); elm.setAttribute(key, '');
} else if (cur === false) { } else if (cur === false) {
elm.removeAttribute(key); elm.removeAttribute(key);
} else { } else {

@ -8,12 +8,12 @@ export type On = {
}; };
function invokeHandler (handler: any, vnode?: VNode, event?: Event): void { function invokeHandler (handler: any, vnode?: VNode, event?: Event): void {
if (typeof handler === "function") { if (typeof handler === 'function') {
// call function handler // call function handler
handler.call(vnode, event, vnode); handler.call(vnode, event, vnode);
} else if (typeof handler === "object") { } else if (typeof handler === 'object') {
// call handler with arguments // call handler with arguments
if (typeof handler[0] === "function") { if (typeof handler[0] === 'function') {
// special case for single argument for performance // special case for single argument for performance
if (handler.length === 2) { if (handler.length === 2) {
handler[0].call(vnode, handler[1], event, vnode); handler[0].call(vnode, handler[1], event, vnode);

@ -150,7 +150,7 @@ export function init (modules: Array<Partial<Module>>, domApi?: DOMAPI) {
if (vnode.children !== undefined) { if (vnode.children !== undefined) {
for (let j = 0; j < vnode.children.length; ++j) { for (let j = 0; j < vnode.children.length; ++j) {
const child = vnode.children[j]; const child = vnode.children[j];
if (child != null && typeof child !== "string") { if (child != null && typeof child !== 'string') {
invokeDestroyHook(child); invokeDestroyHook(child);
} }
} }

@ -186,7 +186,7 @@ describe('snabbdom', function () {
// Only run if srcdoc is supported. // Only run if srcdoc is supported.
var frame = document.createElement('iframe'); var frame = document.createElement('iframe');
if (typeof frame.srcdoc !== 'undefined') { if (typeof frame.srcdoc !== 'undefined') {
frame.srcdoc = "<div>Thing 1</div>"; frame.srcdoc = '<div>Thing 1</div>';
frame.onload = function () { frame.onload = function () {
const div0 = frame.contentDocument!.body.querySelector('div') as HTMLDivElement const div0 = frame.contentDocument!.body.querySelector('div') as HTMLDivElement
patch(div0, h('div', 'Thing 2')); patch(div0, h('div', 'Thing 2'));
@ -362,8 +362,8 @@ describe('snabbdom', function () {
}); });
var h2 = document.createElement('h2'); var h2 = document.createElement('h2');
h2.id = 'hx'; h2.id = 'hx';
h2.setAttribute('data-env', "xyz"); h2.setAttribute('data-env', 'xyz');
var text = document.createTextNode("Foobar"); var text = document.createTextNode('Foobar');
var elm = document.createElement('div'); var elm = document.createElement('div');
elm.id = 'id'; elm.id = 'id';
elm.className = 'class other'; elm.className = 'class other';

@ -154,7 +154,7 @@ describe('event listeners', function () {
it('access to virtual node in event handler with arguments', function () { it('access to virtual node in event handler with arguments', function () {
var result: Array<VNode | Event> = []; var result: Array<VNode | Event> = [];
function clicked (arg1: number, arg2: string, ev: Event, vnode: VNode) { result.push(this); result.push(vnode); } function clicked (arg1: number, arg2: string, ev: Event, vnode: VNode) { result.push(this); result.push(vnode); }
var vnode1 = h('div', { on: { click: [clicked, 1, "2"] as any } }, [ var vnode1 = h('div', { on: { click: [clicked, 1, '2'] as any } }, [
h('a', 'Click my parent'), h('a', 'Click my parent'),
]); ]);
elm = patch(vnode0, vnode1).elm; elm = patch(vnode0, vnode1).elm;

Loading…
Cancel
Save