blob: 975b8b040deeac6486a9f0c7e986e30505ba1049 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/core/scripting_controller.html">
<link rel="import" href="/extras/tquery/filter.html">
<script>
'use strict';
tv.exportTo('tv.e.tquery', function() {
function FilterIsTopLevel(opt_subExpression) {
this.subExpression = opt_subExpression;
}
FilterIsTopLevel.prototype = {
__proto__: tv.e.tquery.Filter.prototype,
set subExpression(expr) {
this.subExpression_ = tv.e.tquery.Filter.normalizeFilterExpression(expr);
},
get subExpression() {
return this.subExpression_;
},
evaluate: function(context) {
if (context.ancestors.length > 0)
return false;
if (!this.subExpression)
return true;
return this.subExpression.evaluate(context);
}
};
tv.c.ScriptingObjectRegistry.register(
function(subExpression) {
return new FilterIsTopLevel(subExpression);
},
{
name: 'isTopLevel'
}
);
return {
FilterIsTopLevel: FilterIsTopLevel
};
});
</script>