aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-05-10 15:34:37 +1000
committerMartin Jones <martin.jones@nokia.com>2011-05-10 15:34:37 +1000
commitf9b198987d2c43395ab4e49532beefbdcf3d2153 (patch)
treeec399ad07f5d1cd443fad5717c0f587e2235fb8a
parente7f900bdc67a2a3fda316037c264d419d1592494 (diff)
parent3cfdb6da04deae9aae3391327e0b8f9cd53e58a3 (diff)
Merge branch 'qtquick2' of scm.dev.nokia.troll.no:qt/qtdeclarative-staging into qtquick2
-rw-r--r--doc/src/declarative/javascriptblocks.qdoc38
1 files changed, 38 insertions, 0 deletions
diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc
index f78f3c264d..90a91b3acd 100644
--- a/doc/src/declarative/javascriptblocks.qdoc
+++ b/doc/src/declarative/javascriptblocks.qdoc
@@ -168,6 +168,44 @@ Notice that calling \l {QML:Qt::include()}{Qt.include()} imports all functions f
\c factorial.js into the \c MyScript namespace, which means the QML component can also
access \c factorial() directly as \c MyScript.factorial().
+In QtQuick 2.0, support has been added to allow JavaScript files to import other
+JavaScript files and also QML modules using a variation of the standard QML import
+syntax (where all of the previously described rules and qualifications apply).
+
+A JavaScript file may import another in the following fashion:
+\code
+.import "filename.js" as UniqueQualifier
+\endcode
+For example:
+\code
+.import "factorial.js" as MathFunctions
+\endcode
+
+A JavaScript file may import a QML module in the following fashion:
+\code
+.import Module.Name MajorVersion.MinorVersion as UniqueQualifier
+\endcode
+For example:
+\code
+.import Qt.test 1.0 as JsQtTest
+\endcode
+In particular, this may be useful in order to access functionality provided
+via a module API; see qmlRegisterModuleApi() for more information.
+
+Due to the ability of a JavaScript file to import another script or QML module in
+this fashion in QtQuick 2.0, some extra semantics are defined:
+\list
+\o a script with imports will not inherit imports from the QML file which imported it (so accessing Component.error will fail, for example)
+\o a script without imports will inherit imports from the QML file which imported it (so accessing Component.error will succeed, for example)
+\o a shared script (i.e., defined as .pragma library) does not inherit imports from any QML file even if it imports no other scripts
+\endlist
+
+The first semantic is conceptually correct, given that a particular script
+might be imported by any number of QML files. The second semantic is retained
+for the purposes of backwards-compatibility. The third semantic remains
+unchanged from the current semantics for shared scripts, but is clarified here
+in respect to the newly possible case (where the script imports other scripts
+or modules).
\section1 Running JavaScript at Startup