本文整理汇总了TypeScript中@ephox/sugar.Attr.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Attr.get方法的具体用法?TypeScript Attr.get怎么用?TypeScript Attr.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/sugar.Attr
的用法示例。
在下文中一共展示了Attr.get方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const fromLink = function (link) {
const text = TextContent.get(link);
const url = Attr.get(link, 'href');
const title = Attr.get(link, 'title');
const target = Attr.get(link, 'target');
return {
url: defaultToEmpty(url),
text: text !== url ? defaultToEmpty(text) : '',
title: defaultToEmpty(title),
target: defaultToEmpty(target),
link: Option.some(link)
};
};
示例2:
Logger.t('Check if iframe has the right custom attributes', Step.sync(function () {
const ifr = Element.fromDom(editor.iframeElement);
Assertions.assertEq('Id should not be the defined x', true, Attr.get(ifr, 'id') !== 'x');
Assertions.assertEq('Custom attribute whould have the right value', 'a', Attr.get(ifr, 'data-custom1'));
Assertions.assertEq('Custom attribute whould have the right value', 'b', Attr.get(ifr, 'data-custom2'));
}))
示例3:
const getAttr = (c, property: string): Option<any> => {
if (Attr.has(c, property)) {
return Option.some(Attr.get(c, property));
} else {
return Option.none();
}
};
示例4: function
const takeoverViewport = function (toolbarHeight, height, viewport) {
const oldViewportStyle = Attr.get(viewport, 'style');
Scrollable.register(viewport);
Css.setAll(viewport, {
position: 'absolute',
// I think there a class that does this overflow scrolling touch part
height: height + 'px',
width: '100%',
top: toolbarHeight + 'px'
});
Attr.set(viewport, yFixedData, toolbarHeight + 'px');
Attr.set(viewport, yScrollingData, 'true');
Attr.set(viewport, yFixedProperty, 'top');
const restore = function () {
Scrollable.deregister(viewport);
Attr.set(viewport, 'style', oldViewportStyle || '');
Attr.remove(viewport, yFixedData);
Attr.remove(viewport, yScrollingData);
Attr.remove(viewport, yFixedProperty);
};
return {
restore
};
};
示例5:
Step.sync(function () {
const component = memento.get(realm.socket());
Assertions.assertEq(
'Selected/Pressed state of component: (' + Attr.get(component.element(), 'class') + ')',
state,
Toggling.isOn(component)
);
}),
示例6:
const cGetDialogLabelId = Chain.binder((dialogE: Element) => {
if (Attr.has(dialogE, 'aria-labelledby')) {
const labelId = Attr.get(dialogE, 'aria-labelledby');
return labelId.length > 0 ? Result.value(labelId) : Result.error('Dialog has zero length aria-labelledby attribute');
} else {
return Result.error('Dialog has no aria-labelledby attribute');
}
});
示例7: function
Arr.each(clobberedEls, function (element) {
const restore = Attr.get(element, attr);
if (restore !== 'no-styles') {
Attr.set(element, 'style', restore);
} else {
Attr.remove(element, 'style');
}
Attr.remove(element, attr);
});
示例8: Error
Chain.op((dialog) => {
if (Attr.has(dialog, 'aria-labelledby')) {
const labelledby = Attr.get(dialog, 'aria-labelledby');
const dialogLabel = SelectorFind.descendant(dialog, '#' + labelledby).getOrDie('Could not find labelledby');
Assertions.assertEq('Checking label text', ariaLabel, Html.get(dialogLabel));
} else {
throw new Error('Dialog did not have an aria-labelledby');
}
})
示例9:
(editor: Editor, onSuccess, onFailure) => {
const replacedElem = Element.fromDom(editor.getElement());
Pipeline.async({ }, [
Chain.asStep(Body.body(), [
UiFinder.cFindIn(`#${Attr.get(replacedElem, 'id')}`),
Chain.binder((elem) => Traverse.nextSibling(elem).fold(() => Result.error('Replaced element has no next sibling'), Result.value)),
Chain.mapper((elem) => Class.has(elem, 'tox-tinymce')),
Assertions.cAssertEq('Replaced element\'s next sibling has "tox-tinymce" class', true)
])
], onSuccess, onFailure);
},