partial fix for event modifier stuff

pull/1839/head
Rich Harris 7 years ago
parent c7d4372f26
commit f452de4a6b

@ -77,14 +77,14 @@ export default class Element extends Node {
type: 'Element';
name: string;
scope: any; // TODO
attributes: Attribute[];
actions: Action[];
bindings: Binding[];
classes: Class[];
handlers: EventHandler[];
intro?: Transition;
outro?: Transition;
animation?: Animation;
attributes: Attribute[] = [];
actions: Action[] = [];
bindings: Binding[] = [];
classes: Class[] = [];
handlers: EventHandler[] = [];
intro?: Transition = null;
outro?: Transition = null;
animation?: Animation = null;
children: Node[];
ref: Ref;
@ -107,16 +107,6 @@ export default class Element extends Node {
});
}
this.attributes = [];
this.actions = [];
this.bindings = [];
this.classes = [];
this.handlers = [];
this.intro = null;
this.outro = null;
this.animation = null;
if (this.name === 'textarea') {
if (info.children.length > 0) {
const valueAttribute = info.attributes.find(node => node.name === 'value');

@ -388,13 +388,14 @@ function readAttribute(parser: Parser, uniqueNames: Set<string>) {
}
if (type) {
const directive_name = name.slice(colon_index + 1);
const [directive_name, ...modifiers] = name.slice(colon_index + 1).split('|');
const directive = {
start,
end,
type,
name: directive_name,
modifiers,
expression: (value[0] && value[0].expression) || null
};

@ -4,6 +4,12 @@ import { SvelteComponent as SvelteComponent_1, addListener, append, createElemen
function create_fragment(component, ctx) {
var div, button0, text1, button1, text3, button2, current;
function click_handler(event) {
event.stopPropagation();
event.preventDefault();
handleClick(event);
}
return {
c() {
div = createElement("div");
@ -15,9 +21,9 @@ function create_fragment(component, ctx) {
text3 = createText("\n\t");
button2 = createElement("button");
button2.textContent = "or me!";
addListener(button0, "click|stopPropagation|preventDefault", handleClick);
addListener(button1, "click|once|capture", handleClick);
addListener(button2, "click|capture", handleClick);
addListener(button0, click_handler);
addListener(button1, "click", handleClick, { once: true, capture: true });
addListener(button2, "click", handleClick, true);
addListener(div, "touchstart", handleTouchstart, { passive: true });
},
@ -45,9 +51,9 @@ function create_fragment(component, ctx) {
detachNode(div);
}
removeListener(button0, "click|stopPropagation|preventDefault", handleClick);
removeListener(button1, "click|once|capture", handleClick);
removeListener(button2, "click|capture", handleClick);
removeListener(button0, click_handler);
removeListener(button1, "click", handleClick, { once: true, capture: true });
removeListener(button2, "click", handleClick, true);
removeListener(div, "touchstart", handleTouchstart, { passive: true });
}
};

@ -15,6 +15,7 @@
"end": 39,
"type": "Action",
"name": "tooltip",
"modifiers": [],
"expression": {
"type": "CallExpression",
"start": 21,

@ -15,6 +15,7 @@
"end": 28,
"type": "Action",
"name": "tooltip",
"modifiers": [],
"expression": {
"type": "Identifier",
"start": 20,

@ -15,6 +15,7 @@
"end": 36,
"type": "Action",
"name": "tooltip",
"modifiers": [],
"expression": {
"type": "Literal",
"start": 21,

@ -15,6 +15,7 @@
"end": 20,
"type": "Action",
"name": "autofocus",
"modifiers": [],
"expression": null
}
],

@ -26,6 +26,7 @@
"end": 50,
"type": "Animation",
"name": "flip",
"modifiers": [],
"expression": null
}
],

@ -15,6 +15,7 @@
"end": 16,
"type": "Binding",
"name": "foo",
"modifiers": [],
"expression": {
"start": 13,
"end": 16,

@ -15,6 +15,7 @@
"end": 24,
"type": "Binding",
"name": "value",
"modifiers": [],
"expression": {
"type": "Identifier",
"start": 19,

@ -15,6 +15,7 @@
"end": 12,
"type": "Ref",
"name": "foo",
"modifiers": [],
"expression": null
}
],

@ -15,6 +15,7 @@
"end": 45,
"type": "EventHandler",
"name": "click",
"modifiers": [],
"expression": {
"type": "ArrowFunctionExpression",
"start": 19,

@ -15,6 +15,7 @@
"end": 15,
"type": "Ref",
"name": "foo",
"modifiers": [],
"expression": null
}
],

@ -15,6 +15,7 @@
"end": 12,
"type": "Transition",
"name": "fade",
"modifiers": [],
"expression": null,
"intro": true,
"outro": false

@ -15,6 +15,7 @@
"end": 30,
"type": "Transition",
"name": "style",
"modifiers": [],
"expression": {
"type": "ObjectExpression",
"start": 16,

@ -3,30 +3,30 @@
"message": "The passive modifier only works with wheel and touch events",
"code": "redundant-event-modifier",
"start": {
"line": 1,
"line": 11,
"column": 8,
"character": 8
"character": 110
},
"end": {
"line": 1,
"line": 11,
"column": 40,
"character": 40
"character": 142
},
"pos": 8
"pos": 110
},
{
"message": "Touch event handlers that don't use the 'event' object are passive by default",
"code": "redundant-event-modifier",
"start": {
"line": 2,
"line": 12,
"column": 5,
"character": 56
"character": 158
},
"end": {
"line": 2,
"line": 12,
"column": 47,
"character": 98
"character": 200
},
"pos": 56
"pos": 158
}
]

Loading…
Cancel
Save