mirror of
https://github.com/liriliri/eruda.git
synced 2026-04-01 10:18:35 +08:00
Fix: Elements select error
This commit is contained in:
14
eustia/isErudaEl.js
Normal file
14
eustia/isErudaEl.js
Normal file
@@ -0,0 +1,14 @@
|
||||
function exports(el)
|
||||
{
|
||||
var parentNode = el.parentNode;
|
||||
|
||||
if (!parentNode) return false;
|
||||
|
||||
while (parentNode)
|
||||
{
|
||||
parentNode = parentNode.parentNode;
|
||||
if (parentNode && parentNode.id === 'eruda') return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -161,8 +161,6 @@ export default class Elements extends Tool
|
||||
}
|
||||
_setEl(el)
|
||||
{
|
||||
if (isErudaEl(el)) return;
|
||||
|
||||
this._curEl = el;
|
||||
this._curCssStore = new CssStore(el);
|
||||
this._highlight.setEl(el);
|
||||
@@ -406,18 +404,3 @@ function rmEvent(el, type, listener, useCapture = false)
|
||||
}
|
||||
|
||||
var getWinEventProto = () => (window.EventTarget && window.EventTarget.prototype) || window.Node.prototype;
|
||||
|
||||
function isErudaEl(el)
|
||||
{
|
||||
let parentNode = el.parentNode;
|
||||
|
||||
if (!parentNode) return false;
|
||||
|
||||
while (parentNode)
|
||||
{
|
||||
parentNode = parentNode.parentNode;
|
||||
if (parentNode && parentNode.id === 'eruda') return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ export default class Select extends util.Emitter
|
||||
|
||||
this._startListener = function (e)
|
||||
{
|
||||
if (util.isErudaEl(e.target)) return;
|
||||
|
||||
self._timer = setTimeout(function ()
|
||||
{
|
||||
self.emit('select', e.target);
|
||||
@@ -25,6 +27,8 @@ export default class Select extends util.Emitter
|
||||
|
||||
this._clickListener = function (e)
|
||||
{
|
||||
if (util.isErudaEl(e.target)) return;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
};
|
||||
|
||||
@@ -1080,6 +1080,28 @@ module.exports = (function ()
|
||||
return exports;
|
||||
})({});
|
||||
|
||||
/* ------------------------------ isErudaEl ------------------------------ */
|
||||
|
||||
var isErudaEl = _.isErudaEl = (function (exports)
|
||||
{
|
||||
function exports(el)
|
||||
{
|
||||
var parentNode = el.parentNode;
|
||||
|
||||
if (!parentNode) return false;
|
||||
|
||||
while (parentNode)
|
||||
{
|
||||
parentNode = parentNode.parentNode;
|
||||
if (parentNode && parentNode.id === 'eruda') return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return exports;
|
||||
})({});
|
||||
|
||||
/* ------------------------------ isFn ------------------------------ */
|
||||
|
||||
var isFn = _.isFn = (function (exports)
|
||||
@@ -1475,42 +1497,6 @@ module.exports = (function ()
|
||||
* |methods|object |Public methods |
|
||||
* |statics|object |Static methods |
|
||||
* |return |function|Function used to create instances|
|
||||
*
|
||||
* ```javascript
|
||||
* var People = Class({
|
||||
* initialize: function (name, age)
|
||||
* {
|
||||
* this.name = name;
|
||||
* this.age = age;
|
||||
* },
|
||||
* introduce: function ()
|
||||
* {
|
||||
* return 'I am ' + this.name + ', ' + this.age + ' years old.'.
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* var Student = People.extend({
|
||||
* initialize: function (name, age, school)
|
||||
* {
|
||||
* this.callSuper('initialize', name, age);
|
||||
*
|
||||
* this.school = school.
|
||||
* },
|
||||
* introduce: function ()
|
||||
* {
|
||||
* return this.callSuper('introduce') + '\n I study at ' + this.school + '.'.
|
||||
* }
|
||||
* }, {
|
||||
* is: function (obj)
|
||||
* {
|
||||
* return obj instanceof Student;
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* var a = new Student('allen', 17, 'Hogwarts');
|
||||
* a.introduce(); // -> 'I am allen, 17 years old. \n I study at Hogwarts.'
|
||||
* Student.is(a); // -> true
|
||||
* ```
|
||||
*/
|
||||
|
||||
var regCallSuper = /callSuper/;
|
||||
|
||||
Reference in New Issue
Block a user