如何使用:not selector in Cytoscape.js? (对于 select 个没有属性的节点)

How to use the :not selector in Cytoscape.js? (To select nodes that don't have an attribute)

我正在尝试使用 :not selector in cytoscape.js。我想 select 所有没有特定属性的节点打开上下文菜单。例如:

cy.cxtmenu({
    selector: not('node.selection'),
    commands: [ .... ]
});

但我不确定如何在 cytoscape.js 中执行此操作。欢迎任何帮助。

[^名字] 如果指定的数据属性未定义,即未定义(例如 [^foo]),则匹配元素。这里,null 被认为是定义的值。

http://js.cytoscape.org/#selectors/data

2022 年更新:

如果您无法控制选择器,而只是想要相反的设置,请使用:

// initialize Cytoscape
let cy = cytoscape()
// select all and remove the rest
cy.$("*").not(cytoscapeSelector)