diff --git a/src/matcher.ts b/src/matcher.ts index 4af62f5..556da13 100644 --- a/src/matcher.ts +++ b/src/matcher.ts @@ -1,4 +1,4 @@ -import { Adapter/*, Predicate*/ } from 'css-select/lib/types'; +import { Adapter /*, Predicate*/ } from 'css-select/lib/types'; import HTMLElement from './nodes/html'; import Node from './nodes/node'; import NodeType from './nodes/type'; @@ -70,7 +70,7 @@ function existsOne(test: Predicate, elems: Node[]): boolean { function getSiblings(node: Node) { const parent = getParent(node); - return parent && getChildren(parent); + return parent ? getChildren(parent) : []; } function hasAttrib(elem: HTMLElement, name: string) { diff --git a/test/assets/html/melon.html b/test/assets/html/melon.html new file mode 100644 index 0000000..6ddb173 --- /dev/null +++ b/test/assets/html/melon.html @@ -0,0 +1,594 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + melonJS + + + + +
The Wayback Machine - https://web.archive.org/web/20201205075004/https://melonjs.org/en
+ + + + + + + Fork me on GitHub + + + + +
+
+

Fresh & Lightweight

+

melonJS is an open source HTML5 game engine that empowers developers and designers to focus on content.

+

+ The framework provides a collection of composable entities and support for a number of third-party tools. Giving you a powerful combination that can be used wholesale or piecemeal. +

+

+ Download + Read The Docs » +

+
+
+ +
+
+
+ +
+
+
+

Try Me!

+
+

Use the following keys to start playing a simple game built with melonJS. Try it with a gamepad!

+
+
+
+ + + + + + + + + + + + +
KeyAction
W SpacebarJump
AWalk Left
SDrop Down
DWalk Right
FFull-Screen Mode
EscExit Game
+
+
+

See you in a bit!

+
+
+ +
+
+

melonJS is a lightweight yet powerful HTML5 framework designed from the ground up to provide a true plugin-free 'write-once, run-everywhere' gaming platform. melonJS is an open-source project and supported by a community of enthusiasts. See our Gallery for a few examples of games powered by melonJS.

+

Getting Started

+
+ +
+
+ +
+
+
+
+

Fast

+ HTML5 +
+

Built with future technology.

+ +
    +
  • WebGL +
  • WebAudio +
  • ES6 Collections +
+
+
+
+

Free

+
+

Released under the permissive MIT License.

+

No cost.

+

Royalty free.

+

Forever.

+
+
+
+

Elegant

+
+

Your scene graph is a hierarchy of containers.

+

Updates and drawing operations are dispatched separately.

+

Draws are opt-in; add compute-only entities for AI, special effects, etc.

+
+
+
+
+
+ +
+
+

Powerful Level Design

+
+

melonJS integrates the popular Tiled map format, allowing designers easily create levels using the Tiled map editor, and to focus on the game features itself.

+ +
+
+ +
+
+

Developer Spotlight

+ + + + + + + + + +
Master Spy by TurbogunRadmars Team - Ludum Dare & GameJam
radmars intro
+ +
+
+ +
+
+
+
+

Features

+
+
    +
  • A fresh and lightweight 2D sprite-based engine +
  • Standalone library (no additional dependencies) +
  • Fast WebGL renderer for desktop and mobile devices with fallback to Canvas rendering +
  • Web Audio support with fallback to Multi-channel HTML5 audio +
  • High DPI & auto scaling video modes +
  • Tween & Transition effects +
  • + Lightweight 2D physics implementation to ensure low cpu requirements +
      +
    • Polygon (SAT) based collision algorithm for accurate detection and response +
    • Fast broad-phase collision detection using spatial partitioning +
    • Advanced math API for Vector and Matrix +
    • 3rd party tools support for physic body definition (PhysicEditor, Physic Body Editor) +
    +
  • + +
  • + A basic set of extensible Object Entities: +
      +
    • Object Pooling +
    • Basic Particle System +
    • Basic animation management +
    • Standard spritesheet and Packed Textures (Texture Packer) support +
    • Some basic GUI elements +
    +
  • + +
  • + Tiled map format integration for easy level design: +
      +
    • Orthogonal, Isometric, Hexagonal, and Perspective tilemap support +
    • Multiple layers with parallax scrolling +
    • Shape-based collision layers (Rectangle, Ellipse, Polygon, and Polyline) +
    • JSON and XML formats +
    +
  • + +
  • System and Bitmap fonts +
  • A state manager and customizable loader +
  • Mouse, Touch, Pointer, and Gamepad device support +
  • Device motion, orientation, and accelerometer support +
  • Built-in support for 3rd party Application Wrappers such as Cordova +
  • As light as ~70kb minified & gzipped +
+
+ +
+ browser icons example +

Compatibility

+
+

melonJS works with any full ES5 compatible browsers

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BrowserVersionStatus
+ Chrome + 55+
Safari10+
Firefox50+
Opera42+
IE11+
Chrome for Mobile55+
iOS Safari9.3+
+
+
+
+
+ +
+
+

Third Party Tools Integration

+
+ melonJS provides native integration and support for the following 3rd party tools : + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/tests/issues/224.js b/test/tests/issues/224.js new file mode 100644 index 0000000..523a590 --- /dev/null +++ b/test/tests/issues/224.js @@ -0,0 +1,11 @@ +const fs = require('fs'); +const { parse } = require('@test/test-target'); + +describe.only('issue 224', function () { + it('query', function () { + const html = fs.readFileSync(__dirname + '/../../assets/html/melon.html', 'utf-8'); + const root = parse(html); + const el = root.querySelector(".band:nth-of-type(3) .col-md-4:nth-of-type(2) h2") + el.tagName.should.eql('H2'); + }); +});