From 0a9540209050e60fbd3bfc4a85b6eb74b0edbe46 Mon Sep 17 00:00:00 2001 From: Stephen D'Angelo Date: Mon, 2 Jan 2017 12:04:27 -0500 Subject: [PATCH 1/2] api: Support assigning qualified qmlelem to a property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit e.g. import QtQuick 2.5 as QQ Repeater { delegate: QQ.Rectangle {} } PR-URL: https://github.com/qmlweb/qmlweb-parser/pull/18 Reviewed-By: Сковорода Никита Андреевич --- src/api.js | 11 +++++++++-- tests/qml/Properties.qml | 2 ++ tests/qml/Properties.qml.json | 28 +++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/api.js b/src/api.js index ca16f3e..929d5b3 100644 --- a/src/api.js +++ b/src/api.js @@ -194,8 +194,15 @@ function qmlweb_parse($TEXT, document_type, exigent_mode) { function maybe_qmlelem(no_in) { var expr = maybe_assign(no_in); - if (is("punc", "{")) - return as("qmlelem", expr[1], undefined, qmlblock()); + if (is("punc", "{")) { + var qmlelem_name; + if (expr[0] === "dot") { + qmlelem_name = ["dot", expr[1][1], expr[2]]; + } else { + qmlelem_name = expr[1]; + } + return as("qmlelem", qmlelem_name, undefined, qmlblock()); + } return expr; } diff --git a/tests/qml/Properties.qml b/tests/qml/Properties.qml index 3c8976a..ddd71de 100644 --- a/tests/qml/Properties.qml +++ b/tests/qml/Properties.qml @@ -1,4 +1,5 @@ import QtQuick 2.5 +import QmlWeb.DOM 1.0 as DOM Rectangle { width: 75 @@ -15,4 +16,5 @@ Rectangle { property var bar: [] property Item item: Item {} property list items + property var domDiv: DOM.Div {} } diff --git a/tests/qml/Properties.qml.json b/tests/qml/Properties.qml.json index 64e254f..e43890c 100644 --- a/tests/qml/Properties.qml.json +++ b/tests/qml/Properties.qml.json @@ -7,6 +7,13 @@ 2.5, "", true + ], + [ + "qmlimport", + "QmlWeb.DOM", + 1, + "DOM", + true ] ], [ @@ -157,7 +164,26 @@ "qmlpropdef", "items", "list" + ], + [ + "qmlpropdef", + "domDiv", + "var", + [ + "stat", + [ + "qmlelem", + [ + "dot", + "DOM", + "Div" + ], + null, + [] + ] + ], + "DOM.Div {}\n" ] ] ] -] +] \ No newline at end of file From 83b9686f73da0938a81025981e86f10a33101e6e Mon Sep 17 00:00:00 2001 From: Stephen D'Angelo Date: Tue, 3 Jan 2017 08:36:02 -0500 Subject: [PATCH 2/2] tests/tape.js: Skip "hidden" . files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some editors (i.e. vi) may put temporary files into the tests directory. Reviewed-By: Сковорода Никита Андреевич --- tests/tape.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/tape.js b/tests/tape.js index a5f8f3b..267490a 100644 --- a/tests/tape.js +++ b/tests/tape.js @@ -13,6 +13,9 @@ function buildTree(dir, data) { data = data || {}; const subdirs = []; for (const file of fs.readdirSync(dir)) { + if (file[0] === ".") { + continue; + } const filePath = path.join(dir, file); if (fs.lstatSync(filePath).isDirectory()) { subdirs.push(filePath);