Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const replacements = require('./src/replacements');
const sources = [
'src/header.js',
'node_modules/uglify-js/lib/parse-js.js',
'src/uglify-js-process.js',
'src/api.js'
];

Expand Down Expand Up @@ -48,6 +49,7 @@ gulp.task('build-covered', ['build-covered-api'], function() {
[
'src/header.js',
'node_modules/uglify-js/lib/parse-js.js',
'src/uglify-js-process.js',
'tmp/api.covered.js'
])
.pipe(order(sources, { base: __dirname }))
Expand Down
25 changes: 23 additions & 2 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ function qmlweb_parse($TEXT, document_type, exigent_mode) {
token_error(S.token, "Unexpected token " + S.token.type + " " + S.token.val + ", expected " + type + " " + val);
};

function qml_get_attached_object(type, val) {
if (type === "name" && qml_is_element(val)) {
return "$QmlWebGetAttachedObject('" + val + "')";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be on the parser side. Parser should just provide a consumable AST.

}
return val
}

var subscripts_js = subscripts;
subscripts = function(expr, allow_calls) {
if (is("punc", ".")) {
next();
expr[1] = qml_get_attached_object(expr[0], expr[1]);
S.token.value = qml_get_attached_object(S.token.type, S.token.value);
return subscripts(as("dot", expr, as_name()), allow_calls);
}
return subscripts_js(expr, allow_calls);
};

var statement_js = statement;
statement = function() {
var in_qmlpropdef = !!statement.in_qmlpropdef;
Expand Down Expand Up @@ -161,12 +179,15 @@ function qmlweb_parse($TEXT, document_type, exigent_mode) {

function as_statement() {
var res = slice(arguments);
var src = "";
S.in_function++;
var start = S.token.pos;
res.push(statement());
var s = statement();
res.push(s);
src += gen_code(s);
var end = S.token.pos;
S.in_function--;
res.push(TEXT.substr(start, end - start));
res.push(src);
return res;
}

Expand Down
Loading